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: Use raise..from in logging/config instead of assigning __cause__
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, vinay.sajip
Priority: normal Keywords: patch

Created on 2022-01-10 14:21 by iritkatriel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30517 merged iritkatriel, 2022-01-10 14:23
Messages (2)
msg410220 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-10 14:39
Lib/logging/config.py has this, which looks like it's partly remnants of old exception handling APIs: 

except ImportError:
    e, tb = sys.exc_info()[1:]
    v = ValueError('Cannot resolve %r: %s' % (s, e))
    v.__cause__, v.__traceback__ = e, tb
    raise v

It is clearer if written as:

except ImportError as e:
    v = ValueError('Cannot resolve %r: %s' % (s, e))
    raise v from e


(note that this doesn't copy the traceback from e to v, but this is redundant information anyway because e is chained to v as the cause).
msg410243 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-10 18:59
New changeset 0d639678d33a0f085851a07259b8fe2782943118 by Irit Katriel in branch 'main':
bpo-46332: use raise..from instead of assigning __cause__ and raising (GH-30517)
https://github.com/python/cpython/commit/0d639678d33a0f085851a07259b8fe2782943118
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90490
2022-01-10 18:59:47iritkatrielsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-10 18:59:35iritkatrielsetmessages: + msg410243
2022-01-10 14:40:07iritkatrielsetmessages: - msg410218
2022-01-10 14:39:59iritkatrielsetmessages: + msg410220
2022-01-10 14:23:10iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28719
2022-01-10 14:22:38iritkatrielsetnosy: + vinay.sajip
2022-01-10 14:21:23iritkatrielcreate