Closed
Description
Bug report
Bug description:
traceback.print_last()
correctly prints the latest traceback for python 3.10.16 and 3.11.9, but it prints NoneType: None
for 3.12.9 and 3.13.2
See also ipython/ipython#14744, I originally thought it was an ipython issue
Python 3.10.16 (main, Feb 13 2025, 14:32:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>> import traceback
>>> traceback.print_last()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
Python 3.11.9 (main, Feb 13 2025, 14:34:41) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>> import traceback
>>> traceback.print_last()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
Python 3.12.9 (main, Feb 13 2025, 13:23:03) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>> import traceback
>>> traceback.print_last()
NoneType: None
Python 3.13.2 (main, Feb 13 2025, 11:10:27) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
1/0
~^~
ZeroDivisionError: division by zero
>>> import traceback
>>> traceback.print_last()
NoneType: None
CPython versions tested on:
3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
- gh-130250: fix regression in traceback.print_last #130318
- [3.13] gh-130250: fix regression in traceback.print_last (GH-130318) #130325
- [3.12] gh-130250: fix regression in traceback.print_last (GH-130318) #130326
- gh-130250: fix cleanup in test (impacts refleaks runs) #130329
- [3.13] gh-130250: fix cleanup in test (impacts refleaks runs) (GH-130329) #130330
- [3.12] gh-130250: fix cleanup in test (impacts refleaks runs) (GH-130329) #130331
- gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state #130342
- [3.13] gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342) #130344
- [3.12] gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342) #130345