New submission from Nils Kattenbeck <nilskem...@gmail.com>: When a FileNotFoundError is raised inside while the importlib.resources.path context manager is active a RuntimeError is raised. Looking at the (3.8) code it seems that FileNotFound exceptions are handled specially from all other exceptions which may lead to this behaviour. While the code in 3.9 changed significantly the same behaviour can be observed.
Files: . └── my_package ├── data.txt (empty) ├── __init__.py (empty) └── test.py Content of test.py: import importlib.resources def main(): with importlib.resources.path('my_package', 'data.txt') as p: raise FileNotFoundError() if __name__ == '__main__': main() Exact error message: RuntimeError: generator didn't stop after throw() ---------- components: Library (Lib) messages: 393686 nosy: Nils Kattenbeck, brett.cannon, jaraco priority: normal severity: normal status: open title: importlib.resources.path raises RuntimeError import FileNotFoundError is raise in context manager type: behavior versions: Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44137> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com