classification
Title: Improve shutdown exception ignored message
Type: behavior Stage: test needed
Components: Interpreter Core Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Broken "Exception ignored in:" message on exceptions in __repr__
View: 22836
Assigned To: Nosy List: jamadagni, martin.panter, r.david.murray, rob.lourens, terry.reedy
Priority: low Keywords: easy, patch

Created on 2009-06-17 00:01 by terry.reedy, last changed 2016-02-28 04:18 by martin.panter. This issue is now closed.

Files
File name Uploaded Description Edit
errors.patch rob.lourens, 2011-02-07 05:32 review
Messages (6)
msg89441 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-06-17 00:01
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?
msg89442 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-06-17 02:50
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
msg89444 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-06-17 06:26
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.
msg89451 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-06-17 10:09
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.
msg128100 - (view) Author: Rob Lourens (rob.lourens) Date: 2011-02-07 05:32
I agree with R. David Murray's suggestions, and have implemented it in the attached patch.
msg233003 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-21 22:17
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 Issue 22836, where I have posted a test and a fix for Python 3.
History
Date User Action Args
2016-02-28 04:18:54martin.pantersetstatus: open -> closed
superseder: Broken "Exception ignored in:" message on exceptions in __repr__
resolution: duplicate
versions: + Python 3.5, Python 3.6, - Python 3.2
2014-12-21 22:17:12martin.pantersetnosy: + martin.panter
messages: + msg233003
2013-05-19 17:00:32jamadagnisetnosy: + jamadagni
2011-02-07 05:32:16rob.lourenssetfiles: + errors.patch

nosy: + rob.lourens
messages: + msg128100

keywords: + patch
2009-06-17 10:09:31r.david.murraysetmessages: + msg89451
2009-06-17 06:26:59terry.reedysetmessages: + msg89444
2009-06-17 02:50:41r.david.murraysetpriority: low

type: enhancement -> behavior
components: + Interpreter Core

nosy: + r.david.murray
messages: + msg89442
stage: test needed
2009-06-17 00:01:50terry.reedycreate