Skip to content
This repository has been archived by the owner on Nov 29, 2019. It is now read-only.

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

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

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

leingang opened this issue Mar 15, 2012 · 2 comments

Comments

@leingang
Copy link

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/

@oxplot
Copy link
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 <
[email protected]

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

@leingang
Copy link
Author

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 as completed 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants