[New-bugs-announce] [issue45083] Incorrect exception output in C

Irit Katriel report at bugs.python.org
Wed Sep 1 17:46:35 EDT 2021


New submission from Irit Katriel <iritkatriel at gmail.com>:

iritkatriel at Irits-MBP cpython % cat exc.py 

class A:
  class B:
    class E(Exception):
      pass

raise A.B.E()

iritkatriel at Irits-MBP cpython % cat test.py 

import exc


iritkatriel at Irits-MBP cpython % ./python.exe test.py 
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython/test.py", line 2, in <module>
    import exc
    ^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython/exc.py", line 7, in <module>
    raise A.B.E()
    ^^^^^^^^^^^^^
exc.E




==============
See the last line of the output: there is no such thing as exc.E. There is exc.A.B.E.

The traceback module doesn't have this issue:

iritkatriel at Irits-MBP cpython % cat test.py 

import traceback

try:
  import exc
except Exception as e:
  traceback.print_exception(e)


iritkatriel at Irits-MBP cpython % ./python.exe test.py 
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython/test.py", line 5, in <module>
    import exc
    ^^^^^^^^^^
  File "/Users/iritkatriel/src/cpython/exc.py", line 7, in <module>
    raise A.B.E()
    ^^^^^^^^^^^^^
exc.A.B.E

----------
components: Interpreter Core
messages: 400873
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: Incorrect exception output in C
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45083>
_______________________________________


More information about the New-bugs-announce mailing list