Commits

Amaury Forgeot d'Arc committed a0e19ad

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

  • Participants
  • Parent commits a7d7bcd
  • Branches py3k

Comments (0)

Files changed (3)

File pypy/module/__builtin__/__init__.py

         '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',

File pypy/module/__builtin__/state.py

 
 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)

File pypy/module/posix/interp_posix.py

             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)