[pypy-commit] pypy py3k: Installs io.open in builtins!

amauryfa noreply at buildbot.pypy.org
Fri Oct 14 01:59:35 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48044:a0e19ad2f880
Date: 2011-10-14 01:59 +0200
http://bitbucket.org/pypy/pypy/changeset/a0e19ad2f880/

Log:	Installs io.open in builtins! Todo: ensure it is also used for
	sys.stdout

diff --git a/pypy/module/__builtin__/__init__.py b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -40,8 +40,7 @@
         'buffer'        : 'interp_memoryview.W_Buffer',
         'memoryview'    : 'interp_memoryview.W_MemoryView',
 
-        'file'          : 'state.get(space).w_file',
-        'open'          : 'state.get(space).w_file',
+        'open'          : 'state.get(space).w_open',
 
         # default __metaclass__: old-style class
         '__metaclass__' : 'interp_classobj.W_ClassObject',
diff --git a/pypy/module/__builtin__/state.py b/pypy/module/__builtin__/state.py
--- a/pypy/module/__builtin__/state.py
+++ b/pypy/module/__builtin__/state.py
@@ -1,9 +1,9 @@
 
 class State:
     def __init__(self, space):
-        self.w_file = space.appexec([], """():
-                import _file;
-                return _file.file""")
+        self.w_open = space.appexec([], """():
+                import io
+                return io.open""")
         
 def get(space):
     return space.fromcache(State)
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -544,13 +544,13 @@
             result = rposix.listdir(dirname)
             w_fs_encoding = getfilesystemencoding(space)
             result_w = [
-                space.call_method(space.wrap(s), "decode", w_fs_encoding)
+                space.call_method(space.wrapbytes(s), "decode", w_fs_encoding)
                 for s in result
             ]
         else:
             dirname = space.str_w(w_dirname)
             result = rposix.listdir(dirname)
-            result_w = [space.wrap(s) for s in result]
+            result_w = [space.wrapbytes(s) for s in result]
     except OSError, e:
         raise wrap_oserror2(space, e, w_dirname)
     return space.newlist(result_w)


More information about the pypy-commit mailing list