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
PyStructSequence_NewType broken in 3.8 #86249
Comments
Calling PyStructSequence_NewType() with a NULL field in the desc.doc parameter (explicitly allowed as per docs) leads to a crash in Objects/typeobject.c:2956 where old_doc is NULL. (stdin):1: DeprecationWarning: builtin type G_SGROUP has no __module__ attribute (where G_SGROUP is my new type), which did not happen in 3.6, and which I do not think can be suppressed by function call arguments. |
It looks like the segfault was fixed in 88c2cfd as part of https://bugs.python.org/issue41832. The code in this area of typeobject.c looks a bit different, now, but the backport seems simple? Simple testcase: #include <stdio.h>
#include <Python.h>
int main() {
Py_Initialize();
PyStructSequence_Field fields[2] = {
{NULL, NULL}
};
PyStructSequence_Desc d = {"test", NULL, &fields[0], 0};
PyStructSequence_NewType(&d);
Py_Finalize();
} Segfault reproducible on 3.8 and 3.9 |
This missed the train for inclusion in 3.8. There's still time for a backport for 3.9. |
Changing PyType_FromSpec* to accept NULL has an issue: extensions built and tested with 3.9.5 would not work with the earlier 3.9s. I'll send a PR to fix just PyStructSequence_NewType. |
Steve, thank you for your invaluable investigation. Thanks Petr for a better fix - your issue didn't come to my mind at the time. Since all PRs have landed and the fix should arrive in Python 3.9.6, I am closing this issue. Please don't hesitate to reopen this if anyone feels it needs revisiting. Thanks! |
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: