diff options
author | Maurits van Rees <maurits@vanrees.org> | 2021-09-02 11:15:07 +0200 |
---|---|---|
committer | Maurits van Rees <maurits@vanrees.org> | 2021-09-03 10:18:37 +0200 |
commit | 74cf43f3dd2d3108548fa0ecc091711ef2ab4eb2 (patch) | |
tree | 99369fa6a221573afc3c95a0ecf81a028bf15cf4 /src/zope/i18n/_compat.py | |
parent | 332629aa14660a10d1e37f02d35847f3229f0844 (diff) | |
download | zope-i18n-74cf43f3dd2d3108548fa0ecc091711ef2ab4eb2.tar.gz |
Add _compat module to define text_type on Py 2 and 3.
The old way worked, but gave a linting error because unicode is not defined.
Diffstat (limited to 'src/zope/i18n/_compat.py')
-rw-r--r-- | src/zope/i18n/_compat.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/zope/i18n/_compat.py b/src/zope/i18n/_compat.py new file mode 100644 index 0000000..00fb20f --- /dev/null +++ b/src/zope/i18n/_compat.py @@ -0,0 +1,8 @@ +# This gives a linting error because unicode is not defined on Python 3: +# text_type = str if bytes is not str else unicode +try: + # Python 3 + text_type = unicode +except NameError: + # Python 2 + text_type = str |