Author: Armin Rigo <[email protected]>
Branch: cffi-embedding-win32
Changeset: r82160:fcdb779aa03c
Date: 2016-02-11 15:59 +0100
http://bitbucket.org/pypy/pypy/changeset/fcdb779aa03c/
Log: follow-up for e1b9c0216be7: move it outside pypy_setup_home(), just
in case, but keep the logic. Add a comment that describes the
problem.
diff --git a/pypy/goal/targetpypystandalone.py
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -105,10 +105,6 @@
space.appexec([w_path], """(path):
import sys
sys.path[:] = path
- import os
- sys.stdin = sys.__stdin__ = os.fdopen(0, 'rb', 0)
- sys.stdout = sys.__stdout__ = os.fdopen(1, 'wb', 0)
- sys.stderr = sys.__stderr__ = os.fdopen(2, 'wb', 0)
""")
# import site
try:
diff --git a/pypy/module/_cffi_backend/embedding.py
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -56,6 +56,24 @@
must_leave = False
try:
must_leave = space.threadlocals.try_enter_thread(space)
+
+ # Annoying: CPython would just use the C-level
+ # std{in,out,err} as configured by the main application,
+ # for example in binary mode on Windows or with buffering
+ # turned off. We can't easily do the same. Instead, go
+ # for the safest bet (but possibly bad for performance)
+ # and open sys.std{in,out,err} unbuffered. On Windows I
+ # guess binary mode is a better default choice.
+ #
+ # XXX if needed, we could add support for a flag passed to
+ # this function.
+ space.appexec([], """():
+ import os
+ sys.stdin = sys.__stdin__ = os.fdopen(0, 'rb', 0)
+ sys.stdout = sys.__stdout__ = os.fdopen(1, 'wb', 0)
+ sys.stderr = sys.__stderr__ = os.fdopen(2, 'wb', 0)
+ """)
+
load_embedded_cffi_module(space, version, init_struct)
res = 0
except OperationError, operr:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit