[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2019-01-15 Thread Ori Avtalion


Ori Avtalion  added the comment:

I encountered a similar bug and reported it as issue 35743.

--
nosy: +salty-horse

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-27 Thread Martin Panter

Martin Panter added the comment:

FTR Python 2’s exception report in __del__() is a bit different, here is what 
it now looks like:

>>> o = VeryBroken()
>>> del o
Exception __main__.BrokenStrException:  in  ignored

--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cf70b1204e44 by Martin Panter in branch '3.5':
Issue #22836: Keep exception reports sensible despite errors
https://hg.python.org/cpython/rev/cf70b1204e44

New changeset 2b597e03f7f4 by Martin Panter in branch 'default':
Issue #22836: Merge exception reporting from 3.5
https://hg.python.org/cpython/rev/2b597e03f7f4

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fca9f02e10e5 by Martin Panter in branch '2.7':
Issue #22836: Keep exception reports sensible despite errors
https://hg.python.org/cpython/rev/fca9f02e10e5

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-25 Thread Martin Panter

Martin Panter added the comment:

Here is a new patch with Victor’s suggestions. The reports now look like

>>> raise BrokenStrException()
Traceback (most recent call last):
  File "", line 1, in 
__main__.BrokenStrException: 
>>> o = VeryBroken()
>>> del o
Exception ignored in: 
Traceback (most recent call last):
  File "", line 9, in __del__
__main__.BrokenStrException: 

--
Added file: http://bugs.python.org/file42029/unraisable-continue.v5.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-24 Thread STINNER Victor

STINNER Victor added the comment:

I like the idea of enhance code writing exception reports, I'm strongly opposed 
to modify repr() to ignore exceptions. I would to be noticed when repr() fails 
badly.

I like how the logging module catchs any formating error and logs an error when 
the formatting fails.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-24 Thread STINNER Victor

STINNER Victor added the comment:

I reviewed unraisable-continue.v4.patch, comments on Rietveld.

Would it be possible to include at least the name of the exception type in the 
error message? It's less likely than writing Py_TYPE(obj)->tp_name failed, than 
error in exc.__str() no?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Surely changing the behavior of repr() can be made only in the default branch. 
this issue needs the patch for all versions.

I don't know whether this is the best solution, but the patch looks good enough 
to me at this moment. If you have no doubts feel free to commit it Martin.

--
assignee:  -> martin.panter
stage: patch review -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-17 Thread Martin Panter

Martin Panter added the comment:

Thanks for the review; here is an updated patch.

If we just fall back the the default, it hides the fact that that there is a 
problem in the custom __repr__() method. Another option may be to both indicate 
there was an error, _and_ a fall back.

--
versions:  -Python 3.4
Added file: http://bugs.python.org/file41948/unraisable-continue.v4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This may be a part of more general issue. Should repr() fail at all? Wouldn't 
be better to fall back to the default __repr__ instead? repr() is typically 
used for debugging. Failing repr() can be a part of larger __repr__, thus 
raising an exception in subobject's repr() leads to the loss of information 
about full object.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-17 Thread Martin Panter

Martin Panter added the comment:

Yes a review would help. Also, I suspect this will require a separate patch for 
Python 2. When I get a chance I will have another look at this and see if I am 
comfortable committing it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2016-02-17 Thread Florian Bruhin

Florian Bruhin added the comment:

I just got bitten by this again - is anything holding this back from being 
merged (other than lack of review-manpower)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2015-06-09 Thread Martin Panter

Martin Panter added the comment:

Updated the patch to address an oversight in the new test cases.

I think Issue 6294 is probably the same underlying issue. The patch there could 
be used as the basis for a Python 2 patch. My patches here are for Python 3, 
and I suspect the code is significantly different in each version, because the 
error messages are different.

Comparison (for bikeshedding etc) with the message produced by the “traceback” 
module when str() fails:

 try:
... raise BrokenStrException(message)
... except BrokenStrException:
... print_exc()
... raise
... 
Traceback (most recent call last):
  File stdin, line 2, in module
BrokenStrException: unprintable BrokenStrException object
Traceback (most recent call last):
  File stdin, line 2, in module
__main__.BrokenStrException: str() failed

--
stage:  - patch review
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file39670/unraisable-continue.v3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-12-21 Thread R. David Murray

R. David Murray added the comment:

See also issue 6294 for a related problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-12-21 Thread Martin Panter

Martin Panter added the comment:

Patch v2 revises the unit tests so they are cleaner. Also now tests that the 
repr() failed placeholders are in the exception reports.

--
Added file: http://bugs.python.org/file37524/unraisable-continue.v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-12-19 Thread Martin Panter

Martin Panter added the comment:

Here is a patch that substitutes an explanation if the repr() fails. Output now 
looks like this, terminated with a newline:

=== BrokenObj ===
Exception ignored in: repr() failed
Traceback (most recent call last):
  File stdin, line 3, in __del__
Exception: in del
$ ./python -c 'import sys; sys.stdout.detach()'
Exception ignored in: repr() failed
ValueError: underlying buffer has been detached

I also made it work sensibly if printing the exception message fails:

 class Exception(Exception):
... def __str__(self): raise Exception(Exception is broken)
... 
 f = BrokenObj(); del f
Exception ignored in: repr() failed
Traceback (most recent call last):
  File stdin, line 3, in __del__
__main__.Exception: str() failed
 raise Exception()
Traceback (most recent call last):
  File stdin, line 1, in module
__main__.Exception: str() failed


--
keywords: +patch
Added file: http://bugs.python.org/file37511/unraisable-continue.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-11-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-11-10 Thread Florian Bruhin

New submission from Florian Bruhin:

When there's an unraisable exception (e.g. in __del__), and there's an 
exception in __repr__ as well, PyErr_WriteUnraisable returns after writing 
Exception ignored in: immediately.

I'd expect it to fall back to the default __repr__ instead.

See the attached example script.

Output with 3.4:

=== Obj ===
Exception ignored in: bound method Obj.__del__ of __main__.Obj object at 
0x7fd842deb4a8
Traceback (most recent call last):
  File test.py, line 4, in __del__
raise Exception('in del')
Exception: in del
=== BrokenObj ===
Exception ignored in: (no newline)

Output with 2.7:

=== Obj ===
Exception Exception: Exception('in del',) in bound method Obj.__del__ of 
__main__.Obj object at 0x7fa824dbfa50 ignored
=== BrokenObj ===
Exception Exception: Exception('in del',) in  ignored

The output with 2.7 is a bit more useful, but still confusing.

--
components: Interpreter Core
files: repr_exception.py
messages: 230950
nosy: The Compiler
priority: normal
severity: normal
status: open
title: Broken Exception ignored in: message on exceptions in __repr__
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file37166/repr_exception.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-11-10 Thread Martin Panter

Martin Panter added the comment:

This is one that has often bugged me. When your repr() implementation is 
broken, it is quite confusing figuring out what is going wrong. Falling back to 
object.__repr__() is one option, however I would probably be happy with a 
simple “exception in repr()” message, and a proper newline.

Another way that I have come across this is:

$ python -c 'import sys; sys.stdout.detach()'
Exception ignored in: [no newline]

The workaround there is to set sys.stdout = None. In that case I think 
repr(sys.stdout) is trying to say “ValueError: underlying buffer has been 
detached”.

--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-11-10 Thread Florian Bruhin

Changes by Florian Bruhin python@the-compiler.org:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22836] Broken Exception ignored in: message on exceptions in __repr__

2014-11-10 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22836
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com