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
PyType_FromSpec
does not copy the name
#89478
Comments
As noted in the issue: https://bugs.python.org/issue15870#msg402800 So, there is no reason to require the string be persistent, and a program that decides to build a custom name dynamically (for whatever reasons) would run into a crash when the name is accessed. The code: Line 3427 in 0c50b8c
Should be modified to point to to the I understand that the FromSpec API is mostly designed to replace the static type definition rather than extend it, but it seems an unintentional/strange requirement. |
Hm, I haven't find any case who use dynamical tp_name of Type_Spec temporarily. |
The use case is creating types entirely on demand, with dynamically created specs. But this issue is not about adding new API to enable a new use case. The *current* API can reasonably be used with a dynamic name string. So we shouldn't wait until someone tells us they need this fixed :) So this should either be fixed or the requirement should be documented. (And the documentation would IMO sound like we're acknowledging a design bug, so it's better to fix.) |
Unfortunately this won't work, because it sets ht_name to the same value as tp_name. For historical reasons, the two can be different (and often are) for types created with PyType_From*Spec*. I haven't found a way to fix this issue without adding yet another pointer to the PyHeapTypeObject struct. |
Since the fix changes the size of PyObject, it can't be backported. |
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: