diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-02-21 12:49:33 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2019-02-21 12:49:33 -0700 |
commit | b6dc039961768bd5f3a3d7f57e8c396f8fa02815 (patch) | |
tree | 2cf18d5b551afd86970ff2d9c55675e071b7786d /numpy/compat/py3k.py | |
parent | 3898fe3fc26245e909c1d2d695b4455f07d4b06c (diff) | |
download | numpy-b6dc039961768bd5f3a3d7f57e8c396f8fa02815.tar.gz |
MAINT: Move pickle import to numpy.compat
The pickle module was being imported from numpy.core.numeric. It was
defined there in order to use pickle5 when available in Python3 and
cpickle in Python2. The numpy.compat module seems a better place for
that.
Diffstat (limited to 'numpy/compat/py3k.py')
-rw-r--r-- | numpy/compat/py3k.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index 8e06ead78..141a21fed 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -8,7 +8,7 @@ __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', 'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested', 'asstr', 'open_latin1', 'long', 'basestring', 'sixu', 'integer_types', 'is_pathlib_path', 'npy_load_module', 'Path', - 'contextlib_nullcontext', 'os_fspath', 'os_PathLike'] + 'pickle', 'contextlib_nullcontext', 'os_fspath', 'os_PathLike'] import sys try: @@ -19,6 +19,11 @@ except ImportError: if sys.version_info[0] >= 3: import io + try: + import pickle5 as pickle + except ImportError: + import pickle + long = int integer_types = (int,) basestring = str @@ -51,8 +56,9 @@ if sys.version_info[0] >= 3: strchar = 'U' - else: + import cpickle as pickle + bytes = str long = long basestring = basestring @@ -76,7 +82,6 @@ else: def sixu(s): return unicode(s, 'unicode_escape') - def getexception(): return sys.exc_info()[1] |