From b6dc039961768bd5f3a3d7f57e8c396f8fa02815 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 21 Feb 2019 12:49:33 -0700 Subject: 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. --- numpy/compat/py3k.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'numpy/compat') 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] -- cgit v1.2.1