Uh oh!
There was an error while loading. Please reload this page.
gh-139852: Add PyObject_GetDictPtr() function - #139854
Conversation
vstinner
commented
Oct 9, 2025
The job fails with: I don't understand this error. Let me try to close/reopen the PR to try to repair the CI. |
vstinner
commented
Oct 9, 2025
I added the |
encukou
commented
Oct 10, 2025
Can those users switch to |
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Oct 10, 2025
It seems like SWIG generates code which writes into the #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
PyObject**dictptr=_PyObject_GetDictPtr(inst);
if (dictptr!=NULL) {
PyObject*dict=*dictptr;
if (dict==NULL) {
dict=PyDict_New();
*dictptr=dict;
}
if (dict) {
PyDict_SetItem(dict, SWIG_This(), swig_this);
} else{
Py_DECREF(inst);
inst=0;
}
}
#elseif (PyObject_SetAttr(inst, SWIG_This(), swig_this) ==-1) {
Py_DECREF(inst);
inst=0;
}
#endifpybind11 also writes into the PyObject **dict_ptr = _PyObject_GetDictPtr(self);
if (dict_ptr) {
Py_CLEAR(*dict_ptr);
}Obviously, there are other usages which only read the dictionary. Example from pybind11: PyObject *&dict = *_PyObject_GetDictPtr(self);
Py_VISIT(dict); |
ZeroIntensity
commented
Oct 10, 2025
That comes up because of the |
| @@ -1550,18 +1571,12 @@ _PyObject_ComputedDictPointer(PyObject *obj) | |||
| PyObject ** | |||
| _PyObject_GetDictPtr(PyObject *obj) | |||
colesbury
commented
Oct 10, 2025
I don't think Swig uses that code path for Python 3: |
vstinner
commented
Oct 11, 2025
Making this API a public function seems to be a bad idea: #139852 (comment). I prefer to close this PR for now. I proposed #139968 to add |
📚 Documentation preview 📚: https://cpython-previews--139854.org.readthedocs.build/