Message289254
main361 can be run as a package from the current directory via -m because an empty string is in sys.path, i.e. the current directory. It imports the package, executing __init__.py and then __main__.py. In this case, the main361 directory/zip import source is not added to sys.path.
When we run main361 as a script, the main361 package is not imported, i.e. __init__.py is not executed. The siblings of the __main__.py script are in the main361 directory (or zip file). Effectively this is the script directory, and it does belong in sys.path -- even in isolated mode because we trust the directory or zip file that contains __main__.py.
A potential problem, however, is that we don't ensure the __main__ import source is added as an absolute path. So if the script changes the working directory, then it loses this import source and possibly (unlikely) gains a new import source if the relative path exists relative to the new working directory. |
|
Date |
User |
Action |
Args |
2017-03-08 19:53:54 | eryksun | set | recipients:
+ eryksun, ncoghlan, nedbat, ned.deily, steve.dower |
2017-03-08 19:53:54 | eryksun | set | messageid: <1489002834.52.0.954692800291.issue29723@psf.upfronthosting.co.za> |
2017-03-08 19:53:54 | eryksun | link | issue29723 messages |
2017-03-08 19:53:54 | eryksun | create | |
|