Author arcivanov
Recipients arcivanov
Date 2020-07-09.18:25:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594319150.59.0.418042347071.issue41261@roundup.psfhosted.org>
In-reply-to
Content
"Short" reproducer:


repro.py:

```
import sys
from os import getcwd, chdir
from runpy import run_path


def smoke_test(script, *args):
    old_argv = list(sys.argv)
    del sys.argv[:]
    sys.argv.append(script)
    sys.argv.extend(args)

    old_modules = dict(sys.modules)
    old_meta_path = list(sys.meta_path)
    old_cwd = getcwd()

    try:
        return run_path(script, run_name="__main__")
    except SystemExit as e:
        if e.code:
            print("Test did not exit successfully")
    finally:
        del sys.argv[:]
        sys.argv.extend(old_argv)

        sys.modules.clear()
        sys.modules.update(old_modules)

        del sys.meta_path[:]
        sys.meta_path.extend(old_meta_path)
        chdir(old_cwd)


smoke_test("script.py")

smoke_test("script.py")
```

script.py:

```
import sys
import subprocess    
import ast

_PYTHON_INFO_SCRIPT = """import platform, sys, os, sysconfig
_executable = os.path.normcase(os.path.abspath(getattr(sys, "_base_executable", sys.executable)))
_platform = sys.platform
if _platform == "linux2":
    _platform = "linux"
print({
    "_platform": _platform,
    "_os_name": os.name,
    "_executable": (_executable, ),
    "_exec_dir": os.path.normcase(os.path.abspath(os.path.dirname(_executable))),
    "_name": platform.python_implementation(),
    "_type": platform.python_implementation().lower(),
    "_version": tuple(sys.version_info),
    "_is_pypy": "__pypy__" in sys.builtin_module_names,
    "_is_64bit": (getattr(sys, "maxsize", None) or getattr(sys, "maxint")) > 2 ** 32,
    "_versioned_dir_name": "%s-%s" % (platform.python_implementation().lower(), ".".join(str(f) for f in sys.version_info)),
    "_environ": dict(os.environ),
    "_darwin_python_framework": sysconfig.get_config_var("PYTHONFRAMEWORK")
})
"""

result = subprocess.check_output([sys.executable, "-c", _PYTHON_INFO_SCRIPT], universal_newlines=True)
python_info = ast.literal_eval(result)
print(python_info)

```
History
Date User Action Args
2020-07-09 18:25:50arcivanovsetrecipients: + arcivanov
2020-07-09 18:25:50arcivanovsetmessageid: <1594319150.59.0.418042347071.issue41261@roundup.psfhosted.org>
2020-07-09 18:25:50arcivanovlinkissue41261 messages
2020-07-09 18:25:50arcivanovcreate