diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-28 17:13:53 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-02 11:23:58 -0600 |
commit | 09a52ed47bb26498c97a579ce1147861df696d84 (patch) | |
tree | 39bbddec620188f8cf09a5eb51370b0db1236219 /numpy/core/setup.py | |
parent | a939f2aa83e7d37d5e35e7c2a8c539c59f682598 (diff) | |
download | numpy-09a52ed47bb26498c97a579ce1147861df696d84.tar.gz |
2to3: Apply `imports` fixer.
The `imports` fixer deals with the standard packages that have been
renamed, removed, or methods that have moved.
cPickle -- removed, use pickle
commands -- removed, getoutput, getstatusoutput moved to subprocess
urlparse -- removed, urlparse moved to urllib.parse
cStringIO -- removed, use StringIO or io.StringIO
copy_reg -- renamed copyreg
_winreg -- renamed winreg
ConfigParser -- renamed configparser
__builtin__ -- renamed builtins
In the case of `cPickle`, it is imported as `pickle` when python < 3 and
performance may be a consideration, but otherwise plain old `pickle` is
used.
Dealing with `StringIO` is a bit tricky. There is an `io.StringIO`
function in the `io` module, available since Python 2.6, but it expects
unicode whereas `StringIO.StringIO` expects ascii. The Python 3
equivalent is then `io.BytesIO`. What I have done here is used BytesIO
for anything that is emulating a file for testing purposes. That is more
explicit than using a redefined StringIO as was done before we dropped
support for Python 2.4 and 2.5.
Closes #3180.
Diffstat (limited to 'numpy/core/setup.py')
-rw-r--r-- | numpy/core/setup.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 37f649e6b..9fe141daf 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -4,12 +4,14 @@ import imp import os import sys import shutil +import pickle +import copy +import warnings +import re from os.path import join from numpy.distutils import log from distutils.dep_util import newer from distutils.sysconfig import get_config_var -import warnings -import re from setup_common import * @@ -22,11 +24,9 @@ ENABLE_SEPARATE_COMPILATION = (os.environ.get('NPY_SEPARATE_COMPILATION', "1") ! # configuration informations between extensions is not easy. # Using a pickled-based memoize does not work because config_cmd is an instance # method, which cPickle does not like. -try: - import cPickle as _pik -except ImportError: - import pickle as _pik -import copy +# +# Use pickle in all cases, as cPickle is gone in python3 and the difference +# in time is only in build. -- Charles Harris, 2013-03-30 class CallOnceOnly(object): def __init__(self): @@ -37,25 +37,25 @@ class CallOnceOnly(object): def check_types(self, *a, **kw): if self._check_types is None: out = check_types(*a, **kw) - self._check_types = _pik.dumps(out) + self._check_types = pickle.dumps(out) else: - out = copy.deepcopy(_pik.loads(self._check_types)) + out = copy.deepcopy(pickle.loads(self._check_types)) return out def check_ieee_macros(self, *a, **kw): if self._check_ieee_macros is None: out = check_ieee_macros(*a, **kw) - self._check_ieee_macros = _pik.dumps(out) + self._check_ieee_macros = pickle.dumps(out) else: - out = copy.deepcopy(_pik.loads(self._check_ieee_macros)) + out = copy.deepcopy(pickle.loads(self._check_ieee_macros)) return out def check_complex(self, *a, **kw): if self._check_complex is None: out = check_complex(*a, **kw) - self._check_complex = _pik.dumps(out) + self._check_complex = pickle.dumps(out) else: - out = copy.deepcopy(_pik.loads(self._check_complex)) + out = copy.deepcopy(pickle.loads(self._check_complex)) return out PYTHON_HAS_UNICODE_WIDE = True |