From 44c4cf53c411d9af1a9a68208a93cfbdd26364ba Mon Sep 17 00:00:00 2001 From: Andrew Brezovsky Date: Mon, 26 Feb 2018 23:12:12 -0500 Subject: [PATCH 1/2] bpo-26792: improve docstrings of runpy module run_ functions --- Lib/runpy.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py index d86f0e4a3c49ba..b285a11fa370de 100644 --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -194,9 +194,23 @@ def _run_module_as_main(mod_name, alter_argv=True): def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): - """Execute a module's code without importing it + """Execute a module's code without importing it. - Returns the resulting top level namespace dictionary + mod_name -- an absolute module name or package name. + + Optional arguments: + init_globals -- dictionary used to pre-populate the module’s + globals dictionary before the code is executed. + + run_name -- sets __name__ if this optional argument is not + None, to mod_name + '.__main__' if the named module is a + package and to the mod_name argument otherwise. + + alter_sys -- if True, sys.argv[0] is updated with the value of + __file__ and sys.modules[__name__] is updated with a temporary + module objectfor the module being executed. + + Returns the resulting top level namespace dictionary. """ mod_name, mod_spec, code = _get_module_details(mod_name) if run_name is None: @@ -237,14 +251,19 @@ def _get_code_from_file(run_name, fname): return code, fname def run_path(path_name, init_globals=None, run_name=None): - """Execute code located at the specified filesystem location + """Execute code located at the specified filesystem location. + + path_name -- filesystem location of a Python script, zipfile, + or directory containing a top level __main__.py script. + + Optional arguments: + init_globals -- dictionary used to pre-populate the module’s + globals dictionary before the code is executed. - Returns the resulting top level namespace dictionary + run_name -- sets __name__ if this optional argument is not + None and to '' otherwise. - The file path may refer directly to a Python script (i.e. - one that could be directly executed with execfile) or else - it may refer to a zipfile or directory containing a top - level __main__.py script. + Returns the resulting top level namespace dictionary. """ if run_name is None: run_name = "" From 84b3689b1404b4e907c2f25d1713423471c27df7 Mon Sep 17 00:00:00 2001 From: Andrew Brezovsky Date: Wed, 28 Feb 2018 02:02:22 -0500 Subject: [PATCH 2/2] fixed whitespace issues found in unix patchcheck --- Lib/runpy.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py index b285a11fa370de..64f013ed02e54b 100644 --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -196,18 +196,18 @@ def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): """Execute a module's code without importing it. - mod_name -- an absolute module name or package name. + mod_name -- an absolute module name or package name. Optional arguments: - init_globals -- dictionary used to pre-populate the module’s + init_globals -- dictionary used to pre-populate the module’s globals dictionary before the code is executed. - run_name -- sets __name__ if this optional argument is not - None, to mod_name + '.__main__' if the named module is a + run_name -- sets __name__ if this optional argument is not + None, to mod_name + '.__main__' if the named module is a package and to the mod_name argument otherwise. - alter_sys -- if True, sys.argv[0] is updated with the value of - __file__ and sys.modules[__name__] is updated with a temporary + alter_sys -- if True, sys.argv[0] is updated with the value of + __file__ and sys.modules[__name__] is updated with a temporary module objectfor the module being executed. Returns the resulting top level namespace dictionary. @@ -253,14 +253,14 @@ def _get_code_from_file(run_name, fname): def run_path(path_name, init_globals=None, run_name=None): """Execute code located at the specified filesystem location. - path_name -- filesystem location of a Python script, zipfile, + path_name -- filesystem location of a Python script, zipfile, or directory containing a top level __main__.py script. Optional arguments: - init_globals -- dictionary used to pre-populate the module’s + init_globals -- dictionary used to pre-populate the module’s globals dictionary before the code is executed. - run_name -- sets __name__ if this optional argument is not + run_name -- sets __name__ if this optional argument is not None and to '' otherwise. Returns the resulting top level namespace dictionary.