diff options
author | Jason Madden <jamadden@gmail.com> | 2017-09-07 17:52:15 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2017-09-07 17:52:15 -0500 |
commit | c0807b6ca629731510ae41ccbcab27570d687546 (patch) | |
tree | ce768e8ec100e65869e924dbe896ee367e86f056 /src/zope/security/_compat.py | |
parent | f2de4625c116085404958724468899dbe784bce6 (diff) | |
download | zope-security-remove_u.tar.gz |
Simplify _compat.py now that we only run on newer Pythonsremove_u
- We have u'literals' so we don't need a _u() function.
For the record the Emacs replacement regex was
`_u(\(['"]\)\([^)]*\)\1) -> u\1\2\1`. Amazingly, I typed that right
on the first try.
A few things were only used in one (test) file or function, so it was
better to keep the use, if any, local and out of the "public" api:
- We can use io.StringIO everywhere and it's fast. It was only
imported in one file anyway.
- We can just import pickle. It was only imported in one file anyway.
- TEXT was only used in one test function, `type(u'')` is just as
clear (especially since the usual name is `text_type`).
- reload was only used in one test function, so move the definition
there.
Diffstat (limited to 'src/zope/security/_compat.py')
-rw-r--r-- | src/zope/security/_compat.py | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/zope/security/_compat.py b/src/zope/security/_compat.py index f3e441f..6c6170f 100644 --- a/src/zope/security/_compat.py +++ b/src/zope/security/_compat.py @@ -22,15 +22,7 @@ py_impl = getattr(platform, 'python_implementation', lambda: None) PYPY = py_impl() == 'PyPy' PURE_PYTHON = os.environ.get('PURE_PYTHON', False) -if sys.version_info[0] < 3: #pragma NO COVER - - from StringIO import StringIO - import cPickle as _pickle - - reload = reload - - def _u(s): - return unicode(s, 'unicode_escape') +if sys.version_info[0] < 3: # pragma: no cover CLASS_TYPES = (type, types.ClassType) _BUILTINS = '__builtin__' @@ -38,17 +30,7 @@ if sys.version_info[0] < 3: #pragma NO COVER PYTHON3 = False PYTHON2 = True - TEXT = unicode - -else: #pragma NO COVER - - from io import StringIO - import pickle as _pickle - - from imp import reload - - def _u(s): - return s +else: # pragma: no cover CLASS_TYPES = (type,) _BUILTINS = 'builtins' @@ -56,6 +38,5 @@ else: #pragma NO COVER PYTHON3 = True PYTHON2 = False - TEXT = str -_BLANK = _u('') +_BLANK = u'' |