New submission from Brett Cannon: As of right now, if you use imp.load_module(), it will store any 'file' argument you give it in a hacked loader. That's a problem when you call imp.reload() on such a module, though, as subsequent calls to __loader__.load_module() will attempt to use the cached file object which was closed on the initial load. What the code should do is use the hacked loader to load the module, but then set an unhacked loader to __loader__ for reloads to work properly.
Traceback below: ====================================================================== ERROR: test_source (test.test_imp.ReloadTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/build/work/cf49a3092a96daebb23bf3c6e0d86ac9/google3/tmp/lib/python3.3/test/test_imp.py", line 248, in test_source imp.reload(os) File "/build/work/cf49a3092a96daebb23bf3c6e0d86ac9/google3/tmp/lib/python3.3/imp.py", line 252, in reload return module.__loader__.load_module(name) File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper File "<frozen importlib._bootstrap>", line 1023, in load_module File "<frozen importlib._bootstrap>", line 1004, in load_module File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper File "<frozen importlib._bootstrap>", line 854, in _load_module File "<frozen importlib._bootstrap>", line 978, in get_code File "/build/work/cf49a3092a96daebb23bf3c6e0d86ac9/google3/tmp/lib/python3.3/imp.py", line 88, in get_data with self.file: ValueError: I/O operation on closed file. ---------- components: Library (Lib) keywords: easy messages: 183549 nosy: brett.cannon priority: normal severity: normal stage: test needed status: open title: imp.load_module() leads to the improper caching of the 'file' argument versions: Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17358> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com