[pypy-commit] pypy py3k: A few more bytes conversion.

amauryfa noreply at buildbot.pypy.org
Thu Oct 13 22:40:28 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48033:eca0000f43ac
Date: 2011-10-13 22:38 +0200
http://bitbucket.org/pypy/pypy/changeset/eca0000f43ac/

Log:	A few more bytes conversion. Have tokenize.py use the io module
	consistently, to be reverted when pypy installs io.open in builtins

diff --git a/lib-python/3.2/tokenize.py b/lib-python/3.2/tokenize.py
--- a/lib-python/3.2/tokenize.py
+++ b/lib-python/3.2/tokenize.py
@@ -30,7 +30,7 @@
 from token import *
 from codecs import lookup, BOM_UTF8
 import collections
-from io import TextIOWrapper
+import io
 cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
 
 import token
@@ -340,10 +340,10 @@
     """Open a file in read only mode using the encoding detected by
     detect_encoding().
     """
-    buffer = builtins.open(filename, 'rb')
+    buffer = io.open(filename, 'rb')
     encoding, lines = detect_encoding(buffer.readline)
     buffer.seek(0)
-    text = TextIOWrapper(buffer, encoding, line_buffering=True)
+    text = io.TextIOWrapper(buffer, encoding, line_buffering=True)
     text.mode = 'r'
     return text
 
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -352,7 +352,7 @@
             raise wrap_oserror(space, e,
                                exception_name='w_IOError')
 
-        return space.wrap(s)
+        return space.wrapbytes(s)
 
     def readinto_w(self, space, w_buffer):
         self._check_closed(space)
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
@@ -37,7 +37,7 @@
     if space.isinstance_w(w_obj, space.w_unicode):
         w_obj = space.call_method(w_obj, 'encode',
                                   getfilesystemencoding(space))
-    return space.str_w(w_obj)
+    return space.bytes_w(w_obj)
 
 class FileEncoder(object):
     def __init__(self, space, w_obj):


More information about the pypy-commit mailing list