Skip to content

Traceback Shows Too Much Info For Class Definition Exception #129145

Open

Description

@ericsnowcurrently

Bug report

Bug description:

Given the following:

class Meta(type):
    def __prepare__(cls, *args, **kwargs):
        raise Exception

class Spam(metaclass=Meta):
    a = 1
    b = 2
    c = 3
    d = 4
    e = 5
    f = 6

I get:

Traceback (most recent call last):
  File "<python-input-10>", line 1, in <module>
    class Spam(metaclass=Meta):
    ...<5 lines>...
        f = 6
  File "<python-input-9>", line 3, in __prepare__
    raise Exception

I would expect this to only show the compound statement's "header":

Traceback (most recent call last):
  File "<python-input-10>", line 1, in <module>
    class Spam(metaclass=Meta):
  File "<python-input-9>", line 3, in __prepare__
    raise Exception

CC @iritkatriel

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Activity

  1. added
    3.14bugs and security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-bugAn unexpected behavior, bug, or error
    on Jan 21, 2025
  2. Eclips4 commented on Jan 21, 2025

    @Eclips4
    Member
  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions