Miguel Brito <miguel.mdebr...@gmail.com> added the comment:

I can reproduce this. From what I can see the issue is that 
`importlib.resources.path` intentionally suppresses `FileNotFoundError` errors.


Based on `importlib.resources.path` docstring I think this is to avoid raising 
an exception if the file is deleted before the context manager exits.

On contextlib.py, since type is not None, it will try to throw the exception 
but since it's supressed nothing will happen and the code will reach the end by 
raising the RuntimeError.


If I'm not mistaken, this is the test that verifies that behaviour: 

I'm not a core dev but it looks like it's an intentional behaviour.

Maybe the docs should be more clear about this. It's not obvious to me when I 
read the docs.

nosy: +miguendes

Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list

Reply via email to