New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importlib/_bootstrap.py write_bytecode raises an IOError if it can't open the .pyc file for writing #51436
Comments
I'm working on an RPM package of Python 3.1.1 for Fedora [1]. Within my RPMs are I see numerous IOError permission errors running the regression test suite, with Here's a minimal reproducer (assuming such an install as above)
>>> from tkinter import Tcl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 151, in decorated
return fxn(self, module)
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 399, in load_module
return self._load_module(module)
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 324, in _load_module
code_object = self.get_code(module.__name__)
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 443, in get_code
self.write_bytecode(fullname, data)
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 171, in inner
return method(self, name, *args, **kwargs)
File "/usr/lib/python3.1/importlib/_bootstrap.py", line 525, in write_bytecode
file = _io.FileIO(bytecode_path, 'w') # Assuming bytes.
IOError: [Errno 13] Permission denied: '/usr/lib/python3.1/tkinter/__init__.pyc' Upon investigating Lib/importlib/_bootstrap.py, the logic for handling permission
So it looks like the try/except clause needs to be extended to also cover opening I'm attaching a patch that makes this change. With this change, the above failing import succeeds, and an invocation of (I'm working on these other failures; some of them are due to errors in my FWIW the initial checkin of py3k/Lib/importlib/_bootstrap.py appears to have the though at that time it was _fileio._FileIO, rather than _io.FileIO. (did FileIO Thanks |
Thanks for the report and potential fix, Dave. I'm swamped at the moment |
Wouldn't the problem disappear, though, if tkinter/init.py didn't |
Aha! Thanks pitrou, looks like I managed to mess up my packaging (I was |
Committed to py3k in r76146 and r76147 for 3.1. Thanks for the detailed report, Dave! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: