[pypy-commit] pypy py3k: make sure to always specify an explicit encoding. Else, _io.open will try to import locale to get the default one, triggering a recursive import and then BOOM

antocuni noreply at buildbot.pypy.org
Tue Feb 28 16:31:35 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52983:df535a5e3932
Date: 2012-02-28 15:39 +0100
http://bitbucket.org/pypy/pypy/changeset/df535a5e3932/

Log:	make sure to always specify an explicit encoding. Else, _io.open
	will try to import locale to get the default one, triggering a
	recursive import and then BOOM

diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -2,6 +2,7 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.module import Module
 from pypy.interpreter.gateway import unwrap_spec
+from pypy.objspace.std import unicodetype
 from pypy.rlib import streamio
 from pypy.module._io.interp_iobase import W_IOBase
 from pypy.module._io import interp_io
@@ -69,7 +70,9 @@
         # open(). However, CPython 3 just passes the fd, so the returned file
         # object doesn't have a name attached. We do the same in PyPy, because
         # there is no easy way to attach the filename -- too bad
-        w_fileobj = interp_io.open(space, space.wrap(fd), find_info.filemode)        
+        encoding = unicodetype.getdefaultencoding(space)
+        w_fileobj = interp_io.open(space, space.wrap(fd), find_info.filemode,
+                                   encoding=encoding)
     else:
         w_fileobj = space.w_None
     w_import_info = space.newtuple(


More information about the pypy-commit mailing list