diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-03-25 03:32:17 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-03-25 03:32:17 +0000 |
commit | 6cf6fd356c70bdf2d6d6d39f052cea9f662ecc07 (patch) | |
tree | 8b397f5002b2d3b9f68bfead5e9b137d95f6e459 /numpy/lib/utils.py | |
parent | c7685e1bac5840a3d040da5cb50291a6cf2cf0d0 (diff) | |
download | numpy-6cf6fd356c70bdf2d6d6d39f052cea9f662ecc07.tar.gz |
BUG: Update StringIO in _lookfor_generate_cache for Python3.x.
Make small cleanup.
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index c406ecd29..a8ad79772 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -6,11 +6,10 @@ import re from numpy.core.numerictypes import issubclass_, issubsctype, issubdtype from numpy.core import product, ndarray -__all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', - 'issubdtype', 'deprecate', 'deprecate_with_doc', - 'get_numarray_include', 'get_include', - 'info', 'source', 'who', 'lookfor', - 'byte_bounds', 'may_share_memory', 'safe_eval'] +__all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', 'issubdtype', + 'deprecate', 'deprecate_with_doc', 'get_numarray_include', + 'get_include', 'info', 'source', 'who', 'lookfor', 'byte_bounds', + 'may_share_memory', 'safe_eval'] def get_include(): """ @@ -848,7 +847,10 @@ def _lookfor_generate_cache(module, import_modules, regenerate): global _lookfor_caches # Local import to speed up numpy's import time. import inspect - from StringIO import StringIO + if sys.version_info[0] >= 3: + from io import BytesIO + else: + from cStringIO import StringIO as BytesIO if module is None: module = "numpy" @@ -916,8 +918,8 @@ def _lookfor_generate_cache(module, import_modules, regenerate): old_stdout = sys.stdout old_stderr = sys.stderr try: - sys.stdout = StringIO() - sys.stderr = StringIO() + sys.stdout = BytesIO() + sys.stderr = BytesIO() __import__("%s.%s" % (name, to_import)) finally: sys.stdout = old_stdout |