This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients steve.dower, vstinner
Date 2017-12-14.16:09:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513267755.86.0.213398074469.issue32324@psf.upfronthosting.co.za>
In-reply-to
Content
Christian Heimes, author of the -I option (isolated mode), asked me to open an issue to check if the following behaviour is correct (safe in term of security).

"python3 directory" inserts "directory" at sys.path[0], even in isolated mode. Example:
---
vstinner@apu$ mkdir directory
vstinner@apu$ echo "import pprint, sys; pprint.pprint(sys.path)" > directory/__main__.py

vstinner@apu$ python3 directory
['directory',
 '/usr/lib64/python3.6',
 ...]

# Same behaviour with -I
vstinner@apu$ python3 -I directory
['directory',
 '/usr/lib64/python3.6',
 ...]
---


Same behaviour for a ZIP file:
---
vstinner@apu$ cd directory/
vstinner@apu$ zip ../testzip.zp __main__.py 
  adding: __main__.py (deflated 20%)
vstinner@apu$ cd ..
vstinner@apu$ python3 testzip.zip
python3: can't open file 'testzip.zip': [Errno 2] No such file or directory
vstinner@apu$ mv testzip.zp testzip.zip 
'testzip.zp' -> 'testzip.zip'

vstinner@apu$ python3 testzip.zip
['testzip.zip',
 '/usr/lib64/python3.6',
 ...]

# Same behaviour with -I
vstinner@apu$ python3 -I testzip.zip
['testzip.zip',
 '/usr/lib64/python3.6',
 ...]
---

The -I option:
https://docs.python.org/dev/using/cmdline.html#id2
History
Date User Action Args
2017-12-14 16:09:15vstinnersetrecipients: + vstinner, steve.dower
2017-12-14 16:09:15vstinnersetmessageid: <1513267755.86.0.213398074469.issue32324@psf.upfronthosting.co.za>
2017-12-14 16:09:15vstinnerlinkissue32324 messages
2017-12-14 16:09:15vstinnercreate