You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2017-09-27.16:28:47.445>created_at=<Date2017-09-26.07:38:12.271>labels= ['interpreter-core', 'type-bug', '3.7']
title='SystemError in class creation in case of a metaclass with a bad __prepare__() method'updated_at=<Date2017-09-27.16:28:47.445>user='https://github.com/orenmn'
The following code causes a SystemError:
This is because builtin___build_class__() assumes that __prepare__() returned a
mapping, and passes it to PyEval_EvalCodeEx(), which passes it to
_PyEval_EvalCodeWithName(), which passes it to _PyFrame_New_NoTrack(), which
raises the SystemError.
There's no __prepare__ method in 2.7, so that version can't be affected by this.
For 3.6 and 3.7, I can't reproduce the reported SystemError. Instead, I get:
>>> class BadMetaclass(type):
... def __prepare__(*args):
>>> class Foo(metaclass=BadMetaclass):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in Foo
TypeError: 'NoneType' object is not subscriptable
The error remains the same if I add @classmethod to the prepare definition.
That's still thoroughly cryptic and worth changing, but indicates the test should be checking the error message details, not just the error type.