-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide CPython command line functionality via runpy module #51065
Comments
Currently, the runpy._run_module_as_main() function allows a launch This RFE suggests making it possible to mimic other command line run_module_as_main - document and make public the existing run_path_as_main - accept a filesystem path and execute it as per the run_file_as_main - accept a file-like object and execute it as per the run_code_as_main - accept a string or code object and execute it The runpy module would also be updated to expose these via its command |
Descoped idea to just provide runpy.run_path (filesystem path equivalent |
2.7: r76286 |
The windows buildbots are reporting an odd error in test_runpy. I can't |
The test is probably failing because the pattern is interpreted as a regex:
>>> re.match(r'\t', r'\t') is None
True There is another problem, which is that test_runpy (or runpy itself) is test_runpy |
The windows errors are most likely due to the fact that I'm not doubling The reference leak is also interesting, since there isn't any new C code |
Hmm, definitely not the path importer cache - regrtest already takes |
There's another cache in zipimport that wasn't being cleared when |
Added to Py3k in r76324 (including the fixes made on 2.x after the |
Another probably related buildbot failure (again, lack of escaping the ====================================================================== Traceback (most recent call last):
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/runpy.py", line
125, in _get_main_module_details
return _get_module_details(main_name)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/runpy.py", line
115, in _get_module_details
raise ImportError("No code object available for %s" % mod_name)
ImportError: No code object available for __main__
During handling of the above exception, another exception occurred: ImportError: can't find '__main__' module in During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/test/test_runpy.py",
line 334, in test_directory_error
self._check_import_error(script_dir, msg)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/test/test_runpy.py",
line 295, in _check_import_error
self.assertRaisesRegexp(ImportError, msg, run_path, script_name)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/unittest/case.py",
line 869, in assertRaisesRegexp
callable_obj(*args, **kwargs)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/unittest/case.py",
line 126, in __exit__
expected_regexp = re.compile(expected_regexp)
File "/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/re.py",
line 205, in compile
return _compile(pattern, flags)
File "/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/re.py",
line 273, in _compile
p = sre_compile.compile(pattern, flags)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_compile.py", line
491, in compile
p = sre_parse.parse(p, flags)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 692, in parse
p = _parse_sub(source, pattern, 0)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 315, in _parse_sub
itemsappend(_parse(source, state))
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 522, in _parse
raise error("multiple repeat")
sre_constants.error: multiple repeat ====================================================================== Traceback (most recent call last):
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/runpy.py", line
125, in _get_main_module_details
return _get_module_details(main_name)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/runpy.py", line
115, in _get_module_details
raise ImportError("No code object available for %s" % mod_name)
ImportError: No code object available for __main__
During handling of the above exception, another exception occurred: ImportError: can't find '__main__' module in During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/test/test_runpy.py",
line 357, in test_zipfile_error
self._check_import_error(zip_name, msg)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/test/test_runpy.py",
line 295, in _check_import_error
self.assertRaisesRegexp(ImportError, msg, run_path, script_name)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/unittest/case.py",
line 869, in assertRaisesRegexp
callable_obj(*args, **kwargs)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/unittest/case.py",
line 126, in __exit__
expected_regexp = re.compile(expected_regexp)
File "/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/re.py",
line 205, in compile
return _compile(pattern, flags)
File "/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/re.py",
line 273, in _compile
p = sre_compile.compile(pattern, flags)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_compile.py", line
491, in compile
p = sre_parse.parse(p, flags)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 692, in parse
p = _parse_sub(source, pattern, 0)
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 315, in _parse_sub
itemsappend(_parse(source, state))
File
"/Users/buildbot/buildarea/3.x.heller-x86-osx5/build/Lib/sre_parse.py",
line 522, in _parse
raise error("multiple repeat")
sre_constants.error: multiple repeat Ran 16 tests in 32.210s |
Hmm, I think I need to use a more robust regex escaping approach... I |
I fixed the tests to use the proper escaping function from the re module (Was it one of the unstable buildbots that picked this up? I didn't see |
Buildbot failures have stopped being e-mailed long ago it seems. |
Antoine Pitrou wrote:
I knew the stable list was a lot shorter than the full list, so I |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: