Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

NameError: global name 'basestring' is not defined (python 3) #1

Closed
leingang opened this Issue Mar 15, 2012 · 2 comments

Comments

Projects
None yet
2 participants

Lines of the form isinstance(init,basestring) raise a NameError in python 3 because there is no such type anymore. Here is a patch which makes the module work in python 3. I put it right after import types

try:
    unicode = unicode
except NameError:
    # 'unicode' is undefined, must be Python 3
    str = str
    unicode = str
    bytes = bytes
    basestring = (str,bytes)
else:
    # 'unicode' exists, must be Python 2
    str = str
    unicode = unicode
    bytes = str
    basestring = basestring

H/T http://www.rfk.id.au/blog/entry/preparing-pyenchant-for-python-3/

Owner

oxplot commented Mar 15, 2012

Thanks a lot for that.

For licensing purposes, by which name would you like to be credited for
this patch? Unless you prefer not to be credited.
Also, is your patch licensed under the same license as that of fysom's?

I'll get this through as soon as you get back to me on those.

Thanks again.
Mansour

On Fri, Mar 16, 2012 at 2:57 AM, leingang <
reply@reply.github.com

wrote:

Lines of the form isinstance(init,basestring) raise a NameError in
python 3 because there is no such type anymore. Here is a patch which
makes the module work in python 3. I put it right after import types

try:
   unicode = unicode
except NameError:
   # 'unicode' is undefined, must be Python 3
   str = str
   unicode = str
   bytes = bytes
   basestring = (str,bytes)
else:
   # 'unicode' exists, must be Python 2
   str = str
   unicode = unicode
   bytes = str
   basestring = basestring

H/T http://www.rfk.id.au/blog/entry/preparing-pyenchant-for-python-3/


Reply to this email directly or view it on GitHub:
#1

I found the snippet on the blog post that I linked to above. It's from a package known as PyEnchant http://packages.python.org/pyenchant/faq.html which is licensed under GNU LGPL. That's compatible with fysom's license, I think.

You can credit me (Matthew Leingang) for the find, but not for the code. :-)

@oxplot oxplot closed this in f89c588 Mar 15, 2012

tsvi added a commit to tsvi/easywebdav that referenced this issue Nov 23, 2014

WildCard65 added a commit to WildCard65/ambuild that referenced this issue Feb 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment