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

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

@leingang

Description

@leingang

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions