This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2015-03-25.00:52:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427244778.02.0.928118006884.issue23763@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2015-03-25 00:52:58vstinnersetrecipients: + vstinner, serhiy.storchaka
2015-03-25 00:52:58vstinnersetmessageid: <1427244778.02.0.928118006884.issue23763@psf.upfronthosting.co.za>
2015-03-25 00:52:57vstinnerlinkissue23763 messages
2015-03-25 00:52:57vstinnercreate