New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemError in class creation in case of a metaclass with a bad __prepare__() method #75769
Comments
The following code causes a SystemError: class Foo(metaclass=BadMetaclass):
pass This is because builtin___build_class__() assumes that __prepare__() returned a This issue seems related to bpo-17421. |
I'm not a metaclass expert. Eric, Nick, could you please take a look at the patch? |
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:
The error remains the same if I add That's still thoroughly cryptic and worth changing, but indicates the test should be checking the error message details, not just the error type. |
Nick, maybe you tried to reproduce in release?
In debug (where I got the SystemError), you have in the beginning of _PyFrame_New_NoTrack():
#ifdef Py_DEBUG
if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
(locals != NULL && !PyMapping_Check(locals))) {
PyErr_BadInternalCall();
return NULL;
} |
Aye, that's exactly what I did. |
CI is still running for the backport, so I'll merge that tomorrow. Thanks for the patch! |
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
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: