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.

classification
Title: suppress context for some exceptions in importlib?
Type: enhancement Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: brett.cannon, eric.snow, python-dev, serhiy.storchaka
Priority: low Keywords: patch

Created on 2013-11-22 18:36 by eric.snow, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
importlib_suppress_context.patch serhiy.storchaka, 2014-11-19 08:54 review
Messages (6)
msg203830 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-11-22 18:36
Some exceptions in importlib are raised from within except blocks, resulting in chained tracebacks. [1]  For at least some of these we should consider suppressing the exception context.

For example (for [1]):

        try:
            path = parent_module.__path__
        except AttributeError:
            msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
            raise ImportError(msg, name=name) from None

[1] http://hg.python.org/cpython/file/default/Lib/importlib/_bootstrap.py#l2088
msg231361 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-19 08:54
Yes, suppressing context was introduced for such cases.

Here is a patch.
msg231476 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-11-21 15:53
LGTM
msg231488 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-21 18:36
New changeset 2de3c659a979 by Serhiy Storchaka in branch 'default':
Issue #19720: Suppressed context for some exceptions in importlib.
https://hg.python.org/cpython/rev/2de3c659a979
msg231493 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-21 20:00
New changeset 8f77f7bb46c7 by Serhiy Storchaka in branch 'default':
Issue #19720: Suppressed context for some exceptions in importlib.
https://hg.python.org/cpython/rev/8f77f7bb46c7
msg231497 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-21 20:04
Sorry, 8f77f7bb46c7 is related to issue17293, not this issue. I have copied wrong commit message from clipboard.
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 63919
2014-11-21 20:04:12serhiy.storchakasetmessages: + msg231497
2014-11-21 20:00:16python-devsetmessages: + msg231493
2014-11-21 20:00:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2014-11-21 18:36:26python-devsetnosy: + python-dev
messages: + msg231488
2014-11-21 15:53:22brett.cannonsetassignee: brett.cannon -> serhiy.storchaka
messages: + msg231476
stage: patch review -> commit review
2014-11-19 15:29:33brett.cannonsetassignee: brett.cannon
2014-11-19 08:54:40serhiy.storchakasetfiles: + importlib_suppress_context.patch

nosy: + serhiy.storchaka
messages: + msg231361

keywords: + patch
stage: needs patch -> patch review
2013-11-22 18:36:50eric.snowcreate