gh-149171: Make TypeAliasType __module__ writable#149172
gh-149171: Make TypeAliasType __module__ writable#149172ericmarkmartin wants to merge 1 commit intopython:mainfrom
Conversation
ddb11af to
73111a0
Compare
picnixz
left a comment
There was a problem hiding this comment.
You should update the TypeAlias docs (both rST and the one at L2193).
| PyObject *old_module = ta->module; | ||
| Py_XDECREF(old_module); | ||
| ta->module = Py_XNewRef(value); |
There was a problem hiding this comment.
Use Py_XSETREF instead. More generally, making it writable looks like we may introduce races on the free-threaded build so I think the getter/setter will need a critical section. I however don't know whether this should be considered an atomic change or not.
Documentation build overview
15 files changed ·
|
| { | ||
| typealiasobject *ta = typealiasobject_CAST(self); | ||
| Py_BEGIN_CRITICAL_SECTION(self); | ||
| Py_XSETREF(ta->module, Py_XNewRef(value)); |
There was a problem hiding this comment.
Minor but we could move the DECREF on the old value outside the critical section. This could theoretically cause issues if the old value has a very expensive destructor.
c506040 to
eaff263
Compare
c0eeb1f to
aa41fd5
Compare
|
CI failures appear to be due to the Canonical outage. I hope to get this in before the beta though. |
closes #149171.