[Numpy-svn] r8305 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Wed Mar 24 22:32:17 CDT 2010


Author: charris
Date: 2010-03-24 22:32:17 -0500 (Wed, 24 Mar 2010)
New Revision: 8305

Modified:
   trunk/numpy/lib/utils.py
Log:
BUG: Update StringIO in _lookfor_generate_cache for Python3.x.
Make small cleanup.

Modified: trunk/numpy/lib/utils.py
===================================================================
--- trunk/numpy/lib/utils.py	2010-03-25 03:32:15 UTC (rev 8304)
+++ trunk/numpy/lib/utils.py	2010-03-25 03:32:17 UTC (rev 8305)
@@ -6,11 +6,10 @@
 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 @@
     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 @@
                             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



More information about the Numpy-svn mailing list