Message402804
| Author |
seberg |
| Recipients |
seberg |
| Date |
2021年09月28日.20:45:06 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1632861906.82.0.496996210358.issue45315@roundup.psfhosted.org> |
| In-reply-to |
| Content |
As noted in the issue: https://bugs.python.org/issue15870#msg402800 `PyType_FromSpec` assumes that the `name` passed is persistent for the program lifetime. This seems wrong/unnecessary: We are creating a heap-type, a heap-type's name is stored as a unicode object anyway!
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:
https://github.com/python/cpython/blob/0c50b8c0b8274d54d6b71ed7bd21057d3642f138/Objects/typeobject.c#L3427
Should be modified to point to to the `ht_name` (utf8) data instead. My guess is, the simplest solution is calling `type_set_name`, even if that runs some unnecessary checks.
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2021年09月28日 20:45:06 | seberg | set | recipients:
+ seberg |
| 2021年09月28日 20:45:06 | seberg | set | messageid: <1632861906.82.0.496996210358.issue45315@roundup.psfhosted.org> |
| 2021年09月28日 20:45:06 | seberg | link | issue45315 messages |
| 2021年09月28日 20:45:06 | seberg | create |
|