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

Improve shutdown exception ignored message #50543

Closed
terryjreedy opened this issue Jun 17, 2009 · 6 comments
Closed

Improve shutdown exception ignored message #50543

terryjreedy opened this issue Jun 17, 2009 · 6 comments
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 6294
Nosy @terryjreedy, @bitdancer, @vadmium
Superseder
  • bpo-22836: Broken "Exception ignored in:" message on exceptions in repr
  • Files
  • errors.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 = None
    closed_at = <Date 2016-02-28.04:18:54.155>
    created_at = <Date 2009-06-17.00:01:50.172>
    labels = ['interpreter-core', 'easy', 'type-bug']
    title = 'Improve shutdown exception ignored message'
    updated_at = <Date 2016-02-28.04:18:54.146>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2016-02-28.04:18:54.146>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-02-28.04:18:54.155>
    closer = 'martin.panter'
    components = ['Interpreter Core']
    creation = <Date 2009-06-17.00:01:50.172>
    creator = 'terry.reedy'
    dependencies = []
    files = ['20707']
    hgrepos = []
    issue_num = 6294
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['89441', '89442', '89444', '89451', '128100', '233003']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'r.david.murray', 'rob.lourens', 'martin.panter', 'jamadagni']
    pr_nums = []
    priority = 'low'
    resolution = 'duplicate'
    stage = 'test needed'
    status = 'closed'
    superseder = '22836'
    type = 'behavior'
    url = 'https://bugs.python.org/issue6294'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @terryjreedy
    Copy link
    Member Author

    When (at least sometimes) exceptions occur during shutdown, warnings
    like the following appear:
    Exception TypeError: "'NoneType' object is not callable" in ignored

    This is apparently meant to be read as
    Exception <<TypeError: "'NoneType' object is not callable" in ...>>
    [was] ignored

    instead of, for instance
    Exception TypeError: "'NoneType' object is not callable" in ignored

    Even when parsed correctly, it is a bit mysterious (who/what ignored the
    exception?) to one not in the know and has generated more than one
    python-list thread.

    Suggestion (from John Machin): reword to something like

    Shutdown ignored this exception: TypeError: "'NoneType' object is not
    callable"

    This would tell people that they might need to find out more about the
    shutdown process.

    Would it be permissible to change this in 3.1?

    @terryjreedy terryjreedy added type-feature A feature request or enhancement easy labels Jun 17, 2009
    @bitdancer
    Copy link
    Member

    Since 3.1 is in final release candidate, a change like this is not
    appropriate for 3.1.

    This error message is generated in PyErr_WriteUnraisable, which is
    called from many contexts, including __del__ methods. A __del__ method
    called during shutdown is most likely what is generating the error you
    are speaking of, but as far as I know the __del__ method has no way to
    know that it is being called during shutdown in particular. So the
    proposed fix to the message won't work.

    The reason this message is so mysterious is that in this particular case
    there is additional information that normally appears in the message
    that has apparently also been nullified during shutdown and that token
    is simply omitted. This appears to be a bug, since the code substitutes
    <unknown> for other elements that are substituted into the message if
    they are NULL, but does not do so for the object passed in to the
    subroutine. Either the fact that the object prints as the empty string
    is a bug, or <unknown> should be substituted for it. With that bug
    fixed, the message would read:

    Exception TypeError: "'NoneType' object is not callable" in <unknown>
    ignored

    which is more easily parsed correctly. As long as we're mucking about
    in that code, though, perhaps a more generic reformatting of the message
    would be clearer even with that bug fixed. I suggest:

    The following Exception of type TypeError was raised in <unknown> but
    was ignored: 'NoneType' object is not callable

    @bitdancer bitdancer added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jun 17, 2009
    @terryjreedy
    Copy link
    Member Author

    I should have said 3.1.1. Ie, would this be a bug fix or really a new
    feature that has to wait. Moot until someone does a patch.

    @bitdancer
    Copy link
    Member

    Ah, in that case then yes, the message bug can be fixed in 3.1.1 and
    2.6.3. As for the message format, the format of messages is not
    considered part of the Python API, but changes to message formats can
    nonetheless cause compatibility issues that would argue for not
    backporting. However, because this is a message you can't even trap it
    should be completely safe to change it.

    @roblourens
    Copy link
    Mannequin

    roblourens mannequin commented Feb 7, 2011

    I agree with R. David Murray's suggestions, and have implemented it in the attached patch.

    @vadmium
    Copy link
    Member

    vadmium commented Dec 21, 2014

    Not sure what the original method to cause this message is. I’m guessing some code was trying to call a function that was set to None by the shutdown process, causing the exception message, and that repr() was also failing, causing the broken wording. Like this:

    $ python2 << PYTHON
    > class C:
    >     def __repr__(self): return None()
    >     def __del__(self): None()
    > x = C()
    > PYTHON
    Exception TypeError: "'NoneType' object is not callable" in  ignored

    If this is the case, then it is the same problem as bpo-22836, where I have posted a test and a fix for Python 3.

    @vadmium vadmium closed this as completed Feb 28, 2016
    @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
    easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants