diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-08-24 11:29:36 +0300 |
---|---|---|
committer | Matti Picus <matti.picus@gmail.com> | 2020-08-24 11:29:36 +0300 |
commit | 8884cfee0bb677aa868aa303d06dcb4ee07d3a0a (patch) | |
tree | d4855e996a3cc3c206752e53aac8f0687bc7d593 | |
parent | Merge branch 'topic/default/bufferedio-release-buffer' into 'branch/default' (diff) | |
download | pypy-8884cfee0bb677aa868aa303d06dcb4ee07d3a0a.tar.gz pypy-8884cfee0bb677aa868aa303d06dcb4ee07d3a0a.tar.bz2 pypy-8884cfee0bb677aa868aa303d06dcb4ee07d3a0a.zip |
use an environment varialble to detect test_app_main. Is this a security risk?
-rwxr-xr-x | pypy/interpreter/app_main.py | 4 | ||||
-rw-r--r-- | pypy/interpreter/test/test_app_main.py | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py index ec5dcab875..27138ce7c2 100755 --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -299,7 +299,9 @@ def initstdio(unbuffered=False): def we_are_translated(): # app-level, very different from rpython.rlib.objectmodel.we_are_translated - return hasattr(sys, 'pypy_translation_info') + # used in test_app_main + import os + os.environ.get('PYPY_IS_UNTRANSLATED', '0') == '1' IS_WINDOWS = 'nt' in sys.builtin_module_names diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py index 4bc76ba84a..ed53363c0c 100644 --- a/pypy/interpreter/test/test_app_main.py +++ b/pypy/interpreter/test/test_app_main.py @@ -100,9 +100,7 @@ class TestParseCommandLine: saved_sys_stdout = sys.stdout saved_sys_stderr = sys.stdout app_main.os = os - def we_are_translated(): - return False - app_main.we_are_translated = we_are_translated + env['PYPY_IS_UNTRANSLATED'] = '1' try: os.environ.update(env) sys.stdout = sys.stderr = StringIO.StringIO() @@ -263,7 +261,9 @@ class TestInteraction: return child def spawn(self, argv): - return self._spawn(sys.executable, [app_main] + argv) + env = os.environ.copy() + env['PYPY_IS_UNTRANSLATED'] = '1' + return self._spawn(sys.executable, [app_main] + argv, env=env) def test_interactive(self): child = self.spawn([]) @@ -647,6 +647,9 @@ class TestInteraction: class TestNonInteractive: def run_with_status_code(self, cmdline, senddata='', expect_prompt=False, expect_banner=False, python_flags='', env=None): + if env is None: + env = os.environ.copy() + env['PYPY_IS_UNTRANSLATED'] = '1' if os.name == 'nt': if __pypy__ is None: py.test.skip('app_main cannot run on non-pypy for windows') @@ -867,6 +870,7 @@ class TestNonInteractive: with chdir_and_unset_pythonpath(tmpdir): data = self.run(cmdline, python_flags='-S') + print data assert data == "some text\n" |