Skip to content

Commit d9db8bb

Browse files
Make sure scripts run with the proper __name__ ("__main__").
1 parent cbe837a commit d9db8bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pythonFiles/pyvsc-run-isolated.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
del sys.path[0]
1414
del sys.argv[0]
1515
module = sys.argv[0]
16-
if module.endswith(".py"):
17-
runpy.run_path(module)
16+
if module.startswith('-'):
17+
raise NotImplementedError(sys.argv)
18+
elif module.endswith(".py"):
19+
runpy.run_path(module, run_name='__main__')
1820
else:
19-
runpy.run_module(module, alter_sys=True)
21+
runpy.run_module(module, run_name='__main__', alter_sys=True)

0 commit comments

Comments
 (0)