[Snowball-discuss] PyStemmer: " 'dict' object has no attribute 'iteritems'" on Python 3

Marc Abramowitz marca at surveymonkey.com
Fri Feb 22 23:50:51 GMT 2013


Also, it would be good to add the Python 3 Trove classifier to indicate Python 3 compatibility — I.e.:

marca at marca-mac:~/dev/surveymonkey/autocompletesvc/snowball/pystemmer$ svn diff setup.py
Index: setup.py
===================================================================
--- setup.py    (revision 560)
+++ setup.py    (working copy)
@@ -101,6 +101,7 @@
       "Programming Language :: C",
       "Programming Language :: Other",
       "Programming Language :: Python",
+      "Programming Language :: Python :: 3",
       "Topic :: Database",
       "Topic :: Internet :: WWW/HTTP :: Indexing/Search",
       "Topic :: Text Processing :: Indexing",

So I'd say make the above tweak to setup.py, build an sdist with the latest version of Cython, push to PyPI, and Python 3 support should be looking pretty good.

Marc

From: Marc Abramowitz <marca at surveymonkey.com<mailto:marca at surveymonkey.com>>
Date: Thursday, February 21, 2013 9:27 PM
To: "snowball-discuss at lists.tartarus.org<mailto:snowball-discuss at lists.tartarus.org>" <snowball-discuss at lists.tartarus.org<mailto:snowball-discuss at lists.tartarus.org>>
Subject: Re: [Snowball-discuss] PyStemmer: " 'dict' object has no attribute 'iteritems'" on Python 3

After messing around with this a bit, I think that my patch is probably not necessary.

I discovered that the code works as-is if I build it myself. It only fails if I pip install PyStemmer.

Based on this, I suspect that the problem is the version of Cython used to build the sdist. Cython 0.11 was used to generate the sdist on PyPI and I have a feeling that this version doesn't know how to generate the appropriate C code needed to translate "iteritems" for Python 3. When I build PyStemmer from source, I'm using Cython 0.17 and this version of Cython probably does the correct translation for Python 3. This is my theory at least. I was hoping to test the theory by installing Cython 0.11 on my Mac, but I've run into problems with building it.

I think all that might be necessary is to generate a new sdist for PyPI using a newer version of Cython.

From: Marc Abramowitz <marca at surveymonkey.com<mailto:marca at surveymonkey.com>>
Date: Thursday, February 21, 2013 12:51 PM
To: "snowball-discuss at lists.tartarus.org<mailto:snowball-discuss at lists.tartarus.org>" <snowball-discuss at lists.tartarus.org<mailto:snowball-discuss at lists.tartarus.org>>
Subject: Re: [Snowball-discuss] PyStemmer: " 'dict' object has no attribute 'iteritems'" on Python 3

An update to my previous message.

I figured out how to do the build. I had to manually download http://snowball.tartarus.org/dist/libstemmer_c.tgz and untar it in the pystemmer directory. That made `python setup.py build`, etc. work.

So then I came up with a patch to fix the "iteritems" issue in __purgeCache on Python 3. Here it is:

https://gist.github.com/msabramo/5008065

I hope that is useful. Thanks for creating and sharing PyStemmer!

Cheers,
Marc
http://marc-abramowitz.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tartarus.org/mailman/private/snowball-discuss/attachments/20130222/41230790/attachment.htm>


More information about the Snowball-discuss mailing list