summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-01-26 14:53:38 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-01-26 14:53:38 (GMT)
commit77b286b2ccccc407d8ed17b0543b10f7c1ccc864 (patch)
tree2e95a1c03b79829ebf72698d61da997f501ef1a5 /Doc
parent23e37aa7b787fd41623c4f3f1eb7ca16ded2ef96 (diff)
downloadcpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.zip
cpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.tar.gz
cpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.tar.bz2
Close #20105: set __traceback__ when chaining exceptions in C
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/exceptions.rst10
-rw-r--r--Doc/whatsnew/3.4.rst8
2 files changed, 18 insertions, 0 deletions
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 8658a58..d4065e0 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -90,6 +90,16 @@ in various ways. There is a separate error indicator for each thread.
the class in that case. If the values are already normalized, nothing happens.
The delayed normalization is implemented to improve performance.
+ .. note::
+
+ This function *does not* implicitly set the ``__traceback__``
+ attribute on the exception value. If setting the traceback
+ appropriately is desired, the following additional snippet is needed::
+
+ if (tb != NULL) {
+ PyException_SetTraceback(val, tb);
+ }
+
.. c:function:: void PyErr_Clear()
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
index 5d397fe..1d88965 100644
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -264,6 +264,9 @@ name of the codec responsible for producing the error::
>>> import codecs
>>> codecs.decode(b"abcdefgh", "hex")
+ Traceback (most recent call last):
+ File "/usr/lib/python3.4/encodings/hex_codec.py", line 20, in hex_decode
+ return (binascii.a2b_hex(input), len(input))
binascii.Error: Non-hexadecimal digit found
The above exception was the direct cause of the following exception:
@@ -273,6 +276,11 @@ name of the codec responsible for producing the error::
binascii.Error: decoding with 'hex' codec failed (Error: Non-hexadecimal digit found)
>>> codecs.encode("hello", "bz2")
+ Traceback (most recent call last):
+ File "/usr/lib/python3.4/encodings/bz2_codec.py", line 17, in bz2_encode
+ return (bz2.compress(input), len(input))
+ File "/usr/lib/python3.4/bz2.py", line 498, in compress
+ return comp.compress(data) + comp.flush()
TypeError: 'str' does not support the buffer interface
The above exception was the direct cause of the following exception: