[pypy-commit] pypy py3k: backout 25989b3230e5: this bootstrap hack is still required (CPython also does

pjenvey pypy.commits at gmail.com
Sat May 21 16:33:45 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r84554:5c6e635923c7
Date: 2016-05-21 13:23 -0700
http://bitbucket.org/pypy/pypy/changeset/5c6e635923c7/

Log:	backout 25989b3230e5: this bootstrap hack is still required (CPython
	also does it) to avoid obscure recursion issues, e.g.
	test_importhooks.testImpWrapper under linux w/ LANG=C. StdErrPrinter
	should make the imports safe now under -v

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
@@ -277,7 +277,16 @@
     if StdErrPrinter is not None:
         sys.stderr = sys.__stderr__ = StdErrPrinter(2)
 
-    if 1:  # keep indentation
+    # Hack to avoid recursion issues during bootstrapping: pre-import
+    # the utf-8 and latin-1 codecs
+    encerr = None
+    try:
+        import encodings.utf_8
+        import encodings.latin_1
+    except ImportError as e:
+        encerr = e
+
+    try:
         if encoding and ':' in encoding:
             encoding, errors = encoding.split(':', 1)
         else:
@@ -296,6 +305,10 @@
             print("Python error: <stdin> is a directory, cannot continue",
                   file=sys.stderr)
             os._exit(1)
+    finally:
+        if encerr:
+            display_exception(encerr)
+            del encerr
 
 def create_stdio(fd, writing, name, encoding, errors, unbuffered):
     import io


More information about the pypy-commit mailing list