Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging exc_info parameter should accept exception instances #64736

Closed
1st1 opened this issue Feb 6, 2014 · 7 comments
Closed

logging exc_info parameter should accept exception instances #64736

1st1 opened this issue Feb 6, 2014 · 7 comments
Assignees
Labels
type-feature A feature request or enhancement

Comments

@1st1
Copy link
Member

1st1 commented Feb 6, 2014

BPO 20537
Nosy @vsajip, @1st1
Files
  • logging_01.patch
  • logging_02.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/vsajip'
    closed_at = <Date 2014-09-14.20:29:31.264>
    created_at = <Date 2014-02-06.23:53:08.124>
    labels = ['type-feature']
    title = 'logging exc_info parameter should accept exception instances'
    updated_at = <Date 2014-09-14.20:29:31.262>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2014-09-14.20:29:31.262>
    actor = 'python-dev'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2014-09-14.20:29:31.264>
    closer = 'python-dev'
    components = []
    creation = <Date 2014-02-06.23:53:08.124>
    creator = 'yselivanov'
    dependencies = []
    files = ['33950', '36614']
    hgrepos = []
    issue_num = 20537
    keywords = ['patch']
    message_count = 7.0
    messages = ['210428', '210436', '210437', '210554', '210559', '226851', '226886']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'python-dev', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue20537'
    versions = ['Python 3.5']

    @1st1
    Copy link
    Member Author

    1st1 commented Feb 6, 2014

    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.

    @1st1 1st1 added the type-feature A feature request or enhancement label Feb 6, 2014
    @vsajip
    Copy link
    Member

    vsajip commented Feb 7, 2014

    I believe it's too late for feature changes in 3.4, so removing it from versions.

    @vsajip vsajip self-assigned this Feb 7, 2014
    @vsajip
    Copy link
    Member

    vsajip commented Feb 7, 2014

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

    @1st1
    Copy link
    Member Author

    1st1 commented Feb 7, 2014

    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?

    @vsajip
    Copy link
    Member

    vsajip commented Feb 7, 2014

    Yes - or I would have said something :-)

    @1st1
    Copy link
    Member Author

    1st1 commented Sep 12, 2014

    Vinay,

    Please take a look at the second patch -- 'logging_02.patch' -- with updated docs

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 14, 2014

    New changeset 9d54903a84b5 by Vinay Sajip in branch 'default':
    Closes bpo-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

    @python-dev python-dev mannequin closed this as completed Sep 14, 2014
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants