Brett Cannon <br...@python.org> added the comment:

The problem with the hybrid exception is that importlib would then still raise 
a different exception from import itself, so the discrepancy would persist. And 
if you updated import you could then break people in another way where they 
were catching ValueError and ImportError separately for different cases and now 
they would potentially catch the wrong exception for that ValueError case.

Basically changing what exceptions get raised sucks as someone is almost 
inevitably broken. But since import and importlib strive to mirror each other 
as much as possible and be drop-in replacements, the consistency for the next 
30 years of Python's life is more important I think than the case of:

1. Someone using importlib.import_module()
2. Who is specifically worried about relative imports going too far and no 
other import-related import and thus only catching ValueError and not 
ImportError
3. And are supporting older versions of Python
4. And will have a difficult time updating their `except` clause to now also 
capture ImportError

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to