
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2012-12-19 14:55 byDavid.Pritchard, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| _bootstrap.py.patch | David.Pritchard,2012-12-19 14:54 | diff patch to fix. | ||
| Messages (8) | |||
|---|---|---|---|
| msg177745 -(view) | Author: David Pritchard (David.Pritchard) | Date: 2012-12-19 14:54 | |
In importlib/_bootstrap.py, there is a function _fill_cache which crashes when you try to run Python in any environment that is so restricted that write permissions are not allowed. You get a trace like:Traceback (most recent call last): In line: [the import statement] File "<frozen importlib._bootstrap>", line 1558, in _find_and_load File "<frozen importlib._bootstrap>", line 1516, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1470, in _find_module File "<frozen importlib._bootstrap>", line 1305, in find_module File "<frozen importlib._bootstrap>", line 1284, in _get_loader File "<frozen importlib._bootstrap>", line 1356, in find_loader File "<frozen importlib._bootstrap>", line 1392, in _fill_cachePermissionError: [Errno 13] Permission denied: '[the directory name]'This was not an issue when I was using Python 3.2 and I suspect it has to do with the OS error refactoring. I believe it can be fixed with a two-line patch, attached. (Sorry if it is the wrong format, it's the first one I've submitted.) The patch simply treats the case of PermissionError the same was as it does when there is a FileNotFoundError. I've tested the patch and it fixes the problem. | |||
| msg177746 -(view) | Author: David Pritchard (David.Pritchard) | Date: 2012-12-19 14:57 | |
Sorry, in the main text of my message, "write permissions" should say directory execute permissions (permission to list contents of a directory) | |||
| msg177769 -(view) | Author: Eric Snow (eric.snow)*![]() | Date: 2012-12-19 17:58 | |
Patch looks good to me. Are there any other exceptions that might be included here? | |||
| msg177776 -(view) | Author: Brett Cannon (brett.cannon)*![]() | Date: 2012-12-19 20:22 | |
If Antoine can't think of any then I think there aren't any more. This does need a test, though. | |||
| msg178963 -(view) | Author: Christian Heimes (christian.heimes)*![]() | Date: 2013-01-03 16:35 | |
NotADirectoryError is missing from the list of exception. The error can occur when the directory is removed and replaced by an ordinary file. | |||
| msg178986 -(view) | Author: David Pritchard (David.Pritchard) | Date: 2013-01-03 20:30 | |
Here's an example where Python 3.3.0 crashes, but where the patched code works. I have only been able to trigger the bug when PYTHONPATH is set (even if to an empty value). (1) create a directory(2) chmod a-rw+x on that directory(3) export PYTHONPATH=""(4) python3 from within that directory: should crash on loadingNote, without step (3) the error does not occur. Alternatively, do (1), (2),(3') set PYTHONPATH to that -rw'ed directory(4') python3 from outside of that directory: should crash on loading | |||
| msg179729 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2013-01-11 20:45 | |
New changeset159967aa24a5 by Brett Cannon in branch '3.3':Issue#16730: Don't raise an exception inhttp://hg.python.org/cpython/rev/159967aa24a5New changesetb94f308e9b47 by Brett Cannon in branch 'default':Merge from 3.3 for fix for issue#16730http://hg.python.org/cpython/rev/b94f308e9b47 | |||
| msg179730 -(view) | Author: Brett Cannon (brett.cannon)*![]() | Date: 2013-01-11 20:46 | |
Tests added for both the file and unreadable cases and the appropriate exceptions now caught. Thanks to everyone for helping with this! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:39 | admin | set | github: 60934 |
| 2013-01-11 20:46:09 | brett.cannon | set | status: open -> closed versions: + Python 3.4 messages: +msg179730 resolution: fixed stage: test needed -> resolved |
| 2013-01-11 20:45:12 | python-dev | set | nosy: +python-dev messages: +msg179729 |
| 2013-01-08 16:02:14 | jcea | set | nosy: +jcea |
| 2013-01-03 20:30:39 | David.Pritchard | set | messages: +msg178986 |
| 2013-01-03 16:35:19 | christian.heimes | set | nosy: +christian.heimes messages: +msg178963 |
| 2013-01-03 04:47:50 | meador.inge | set | nosy: +meador.inge |
| 2012-12-19 20:23:01 | brett.cannon | set | type: behavior stage: test needed |
| 2012-12-19 20:22:46 | brett.cannon | set | messages: +msg177776 |
| 2012-12-19 17:58:40 | eric.snow | set | nosy: +eric.snow,brett.cannon messages: +msg177769 |
| 2012-12-19 15:17:02 | skrah | set | nosy: +pitrou |
| 2012-12-19 14:57:32 | David.Pritchard | set | messages: +msg177746 |
| 2012-12-19 14:55:01 | David.Pritchard | create | |