Author: mattip <[email protected]>
Branch:
Changeset: r60944:e89396c9a1d0
Date: 2013-02-07 23:23 +0200
http://bitbucket.org/pypy/pypy/changeset/e89396c9a1d0/
Log: merge heads, fix numpypy scalar crashes
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
@@ -436,11 +436,14 @@
# (relevant in case of "reload(sys)")
sys.argv[:] = argv
- if PYTHON26 and not options["ignore_environment"]:
- if os.getenv('PYTHONNOUSERSITE'):
- options["no_user_site"] = 1
- if os.getenv('PYTHONDONTWRITEBYTECODE'):
- options["dont_write_bytecode"] = 1
+ if not options["ignore_environment"]:
+ if os.getenv('PYTHONUNBUFFERED'):
+ options["unbuffered"] = 1
+ if PYTHON26:
+ if os.getenv('PYTHONNOUSERSITE'):
+ options["no_user_site"] = 1
+ if os.getenv('PYTHONDONTWRITEBYTECODE'):
+ options["dont_write_bytecode"] = 1
if (options["interactive"] or
(not options["ignore_environment"] and os.getenv('PYTHONINSPECT'))):
@@ -716,7 +719,7 @@
root = dn(dn(dn(thisfile)))
return [join(root, 'lib-python', '2.7'),
join(root, 'lib_pypy')]
-
+
def pypy_resolvedirof(s):
# we ignore the issue of symlinks; for tests, the executable is always
# interpreter/app_main.py anyway
@@ -756,6 +759,10 @@
del os # make sure that os is not available globally, because this is what
# happens in "real life" outside the tests
+ if 'time' not in sys.builtin_module_names:
+ # make some tests happy by loading this before we clobber sys.path
+ import time; del time
+
# no one should change to which lists sys.argv and sys.path are bound
old_argv = sys.argv
old_path = sys.path
diff --git a/pypy/interpreter/test2/test_app_main.py
b/pypy/interpreter/test2/test_app_main.py
--- a/pypy/interpreter/test2/test_app_main.py
+++ b/pypy/interpreter/test2/test_app_main.py
@@ -712,6 +712,26 @@
assert data == '\x00(STDOUT)\n\x00' # from stdout
child_out_err.close()
+ def test_non_interactive_stdout_unbuffered(self, monkeypatch):
+ monkeypatch.setenv('PYTHONUNBUFFERED', '1')
+ path = getscript(r"""
+ import sys, time
+ sys.stdout.write('\x00(STDOUT)\n\x00')
+ time.sleep(1)
+ sys.stderr.write('\x00[STDERR]\n\x00')
+ time.sleep(1)
+ # stdout flushed automatically here
+ """)
+ cmdline = '%s -E "%s" %s' % (sys.executable, app_main, path)
+ print 'POPEN:', cmdline
+ child_in, child_out_err = os.popen4(cmdline)
+ data = child_out_err.read(11)
+ assert data == '\x00(STDOUT)\n\x00' # from stderr
+ data = child_out_err.read(11)
+ assert data == '\x00[STDERR]\n\x00' # from stdout
+ child_out_err.close()
+ child_in.close()
+
def test_proper_sys_path(self, tmpdir):
data = self.run('-c "import _ctypes"', python_flags='-S')
if data.startswith('Traceback'):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit