File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Fix isolate script to only remove current working directory.
Original file line number Diff line number Diff line change 44if __name__ != "__main__" :
55 raise Exception ("{} cannot be imported" .format (__name__ ))
66
7+ import os
78import os .path
89import runpy
910import sys
1011
11- # We "isolate" the script/module (sys.argv[1]) by
12- # replacing sys.path[0] with a dummy path and then sending the target
13- # on to runpy.
14- sys .path [0 ] = os .path .join (os .path .dirname (__file__ ), ".does-not-exist" )
12+
13+ def normalize (path ):
14+ return os .path .normcase (os .path .normpath (path ))
15+
16+
17+ # We "isolate" the script/module (sys.argv[1]) by removing current working
18+ # directory or '' in sys.path and then sending the target on to runpy.
19+ cwd = normalize (os .getcwd ())
20+ sys .path [:] = (p for p in sys .path if p != "" and normalize (p ) != cwd )
1521del sys .argv [0 ]
1622module = sys .argv [0 ]
1723if module == "-c" :
You can’t perform that action at this time.
0 commit comments