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 Nils Kattenbeck
Recipients Nils Kattenbeck, brett.cannon, jaraco
Date 2021-05-14.19:29:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621020560.88.0.325550849747.issue44137@roundup.psfhosted.org>
In-reply-to
Content
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()
History
Date User Action Args
2021-05-14 19:29:20Nils Kattenbecksetrecipients: + Nils Kattenbeck, brett.cannon, jaraco
2021-05-14 19:29:20Nils Kattenbecksetmessageid: <1621020560.88.0.325550849747.issue44137@roundup.psfhosted.org>
2021-05-14 19:29:20Nils Kattenbecklinkissue44137 messages
2021-05-14 19:29:20Nils Kattenbeckcreate