[pypy-commit] pypy py3.3-bootstrap-hack: Initialise the filesystem encoding only after imports have been bootstrapped.
rlamy
pypy.commits at gmail.com
Thu Mar 10 14:02:55 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.3-bootstrap-hack
Changeset: r82949:eb02742ce71d
Date: 2016-03-10 19:01 +0000
http://bitbucket.org/pypy/pypy/changeset/eb02742ce71d/
Log: Initialise the filesystem encoding only after imports have been
bootstrapped.
Creating it requires importing the 'encodings' module from the
stdlib, so the stdlib path needs to have been computed first.
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -769,6 +769,7 @@
# import os, which is used a bit everywhere in app_main, but only imported
# *after* setup_bootstrap_path
setup_bootstrap_path(executable)
+ sys.pypy_initfsencoding()
try:
cmdline = parse_command_line(argv)
except CommandLineError as e:
@@ -862,7 +863,7 @@
sys.pypy_find_stdlib = pypy_find_stdlib
sys.pypy_resolvedirof = pypy_resolvedirof
sys.cpython_path = sys.path[:]
-
+
try:
sys.exit(int(entry_point(sys.argv[0], sys.argv[1:])))
finally:
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -40,6 +40,7 @@
'pypy_find_stdlib' : 'initpath.pypy_find_stdlib',
'pypy_find_executable' : 'initpath.pypy_find_executable',
'pypy_resolvedirof' : 'initpath.pypy_resolvedirof',
+ 'pypy_initfsencoding' : 'initpath.pypy_initfsencoding',
'_getframe' : 'vm._getframe',
'_current_frames' : 'currentframes._current_frames',
@@ -97,12 +98,7 @@
def startup(self, space):
if space.config.translating:
- if not we_are_translated():
- # don't get the filesystemencoding at translation time
- assert self.filesystemencoding is None
- else:
- from pypy.module.sys.interp_encoding import _getfilesystemencoding
- self.filesystemencoding = _getfilesystemencoding(space)
+ assert self.filesystemencoding is None
if not space.config.translating or we_are_translated():
from pypy.module.sys import version
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -12,6 +12,7 @@
from pypy.interpreter.gateway import unwrap_spec
from pypy.module.sys.state import get as get_state
+from pypy.module.sys.interp_encoding import _getfilesystemencoding
PLATFORM = sys.platform
_MACOSX = sys.platform == 'darwin'
@@ -166,7 +167,9 @@
space.setitem(space.sys.w_dict, space.wrap('base_exec_prefix'), w_prefix)
return space.newlist([_w_fsdecode(space, p) for p in path])
+def pypy_initfsencoding(space):
+ space.sys.filesystemencoding = _getfilesystemencoding(space)
+
def _w_fsdecode(space, b):
return space.fsdecode(space.wrapbytes(b))
-
More information about the pypy-commit
mailing list