classification
Title: logging exc_info parameter should accept exception instances
Type: enhancement Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: python-dev, vinay.sajip, yselivanov
Priority: normal Keywords: patch

Created on 2014-02-06 23:53 by yselivanov, last changed 2014-09-14 20:29 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
logging_01.patch yselivanov, 2014-02-06 23:53 review
logging_02.patch yselivanov, 2014-09-12 23:07 review
Messages (7)
msg210428 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-02-06 23:53
A bunch of logging methods accept optional parameter exc_info, that is supposed to be either 'True' or a tuple of three elements (type, exc, tb).

If, however, someone passes an actual exception instance, Logger._log function will interpret it as True and get the current exception from sys.exc_info, ignoring the passed exception completely.

Attached is a patch that fixes this: if exc_info is an instance of BaseException, Logger._log creates the tuple out of it automatically.
msg210436 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-02-07 06:36
I believe it's too late for feature changes in 3.4, so removing it from versions.
msg210437 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-02-07 06:38
It would be good if the patch addressed documentation changes, too :-)
msg210554 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-02-07 20:54
> I believe it's too late for feature changes in 3.4, so removing it from versions.

Alright. Was worth a try ;)

> It would be good if the patch addressed documentation changes, too :-)

Sure, I'll add the documentation, when we start working on 3.5.

Are you OK with the general idea of the patch?
msg210559 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-02-07 21:29
Yes - or I would have said something :-)
msg226851 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-09-12 23:07
Vinay,

Please take a look at the second patch -- 'logging_02.patch' -- with updated docs
msg226886 - (view) Author: Roundup Robot (python-dev) Date: 2014-09-14 20:29
New changeset 9d54903a84b5 by Vinay Sajip in branch 'default':
Closes #20537: logging methods now accept an exception instance as well as a Boolean value or exception tuple. Thanks to Yury Selivanov for the patch.
https://hg.python.org/cpython/rev/9d54903a84b5
History
Date User Action Args
2014-09-14 20:29:31python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg226886

resolution: fixed
stage: resolved
2014-09-12 23:07:27yselivanovsetfiles: + logging_02.patch

messages: + msg226851
2014-02-07 21:29:27vinay.sajipsetmessages: + msg210559
2014-02-07 20:54:24yselivanovsetmessages: + msg210554
2014-02-07 06:38:54vinay.sajipsetmessages: + msg210437
2014-02-07 06:36:44vinay.sajipsetassignee: vinay.sajip
messages: + msg210436
versions: - Python 3.4
2014-02-06 23:53:08yselivanovcreate