Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Traceback Shows Too Much Info For Class Definition Exception #129145

Open
@ericsnowcurrently

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions