109 """ |
109 """ |
110 pathname, packagename = find_module(modulename) |
110 pathname, packagename = find_module(modulename) |
111 |
111 |
112 pathname = os.path.abspath(pathname) |
112 pathname = os.path.abspath(pathname) |
113 args[0] = pathname |
113 args[0] = pathname |
114 run_python_file(pathname, args, package=packagename, modulename=modulename, path0="") |
114 # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It |
|
115 # used to be an empty string (meaning the current directory). It changed |
|
116 # to be the actual path to the current directory, so that os.chdir wouldn't |
|
117 # affect the outcome. |
|
118 if sys.version_info >= (3, 7, 0, 'beta', 3): |
|
119 path0 = os.getcwd() |
|
120 else: |
|
121 path0 = "" |
|
122 run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0) |
115 |
123 |
116 |
124 |
117 def run_python_file(filename, args, package=None, modulename=None, path0=None): |
125 def run_python_file(filename, args, package=None, modulename=None, path0=None): |
118 """Run a Python file as if it were the main program on the command line. |
126 """Run a Python file as if it were the main program on the command line. |
119 |
127 |