STINNER Victor added the comment:
pyerr_chain.patch: The real patch to chain automatically exceptions when using
PyErr_*() functions.
pyerr_match_clear-2.patch hides the original exception when it is useless, too
low level like OverflowError when casting to C types, etc.
Examples without pyerr_match_clear-2.patch.
int, before:
| $ python3 -c 'int("123z")'
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| ValueError: invalid literal for int() with base 10: '123z'
int, after:
| $ ./python -c 'int("123z")'
| ValueError: invalid literal for int() with base 10: '123z'
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| ValueError: invalid literal for int() with base 10: '123z'
struct, before:
| $ python3 -c 'import struct; struct.pack("b", 2**100)'
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| struct.error: argument out of range
struct, after:
| $ ./python -c 'import struct; struct.pack("b", 2**100)'
| OverflowError: Python int too large to convert to C long
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "<string>", line 1, in <module>
| struct.error: argument out of range
More examples, after (still without pyerr_match_clear-2.patch):
int(str):
| TypeError: a bytes-like object is required, not 'type'
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "<stdin>", line 1, in <module>
| TypeError: int() argument must be a string, a bytes-like object or a number,
not 'type'
''.join(str):
| TypeError: 'type' object is not iterable
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "<stdin>", line 1, in <module>
| TypeError: can only join an iterable
b"%f" % "abc":
| TypeError: a float is required
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
| File "<stdin>", line 1, in <module>
| TypeError: float argument required, not str
----------
Added file: http://bugs.python.org/file38679/pyerr_chain.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com