Terry J. Reedy added the comment:
I marked this as 3.3+ bug because double reporting is new in 3.x and 'from
None' is new in 3.3 (it causes a TypeError in the raise statement ;-).
Command prompt output appears 'correct' (as intended).
[I added blank lines before each try: for reading ease]
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17)
[MSC v.1600 64 bit (AMD64)] on win32
>>> try:
... 1/0
... except ZeroDivisionError as exp:
... raise TypeError('Divided by 0')
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
TypeError: Divided by 0
>>> try:
... 1/0
... except ZeroDivisionError as exp:
... raise TypeError('Divided by 0') from exp
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
TypeError: Divided by 0
>>> try:
... 1/0
... except ZeroDivisionError as exp:
... raise TypeError('Divided by 0') from None
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
TypeError: Divided by 0
---------------------------------------------------
In IDLE on Win 7 64, all three give
Traceback (most recent call last):
File "F:\Python\mypy\tem.py", line 4, in <module>
raise TypeError('Divided by 0') # except for change here
TypeError: Divided by 0
We need to see non-Windows IDLE output to see if problem is limited to running
with pythonw. Here is copy-paste code.
try:
1/0
except ZeroDivisionError as exp:
raise TypeError('Divided by 0') from None
----------
nosy: +serwy, terry.reedy
stage: -> needs patch
title: try-except-raise-bug -> IDLE and except: raise from
versions: +Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16491>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com