Skip to content

traceback.print_last behaving differently across python versions#130250

@mironleon

Description

@mironleon

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

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions