mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #19700: set __spec__ appropriately in runpy
Note that __spec__.name is not currently guaranteed to be in sys.modules when the code is running, only __name__ is. The "running module is in sys.modules" invariant will be expanded to also cover __spec__.name in a subsequent patch.
This commit is contained in:
parent
8aa36a3db9
commit
720c7e28cb
5 changed files with 276 additions and 112 deletions
|
@ -101,8 +101,10 @@ def kill_python(p):
|
|||
subprocess._cleanup()
|
||||
return data
|
||||
|
||||
def make_script(script_dir, script_basename, source):
|
||||
script_filename = script_basename+os.extsep+'py'
|
||||
def make_script(script_dir, script_basename, source, omit_suffix=False):
|
||||
script_filename = script_basename
|
||||
if not omit_suffix:
|
||||
script_filename += os.extsep + 'py'
|
||||
script_name = os.path.join(script_dir, script_filename)
|
||||
# The script should be encoded to UTF-8, the default string encoding
|
||||
script_file = open(script_name, 'w', encoding='utf-8')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue