summaryrefslogtreecommitdiffstats
path: root/Include/objimpl.h
diff options
context:
space:
mode:
authorEddie Elizondo <eduardo.elizondorueda@gmail.com>2019-03-27 11:52:18 (GMT)
committerPetr Viktorin <encukou@gmail.com>2019-03-27 11:52:18 (GMT)
commit364f0b0f19cc3f0d5e63f571ec9163cf41c62958 (patch)
tree977c0c418780824cca9ef9b4d920b9d423253e84 /Include/objimpl.h
parent1fc5bf2ff27b898e8d9460d0fbc791e83009ed71 (diff)
downloadcpython-364f0b0f19cc3f0d5e63f571ec9163cf41c62958.zip
cpython-364f0b0f19cc3f0d5e63f571ec9163cf41c62958.tar.gz
cpython-364f0b0f19cc3f0d5e63f571ec9163cf41c62958.tar.bz2
bpo-35810: Incref heap-allocated types in PyObject_Init (GH-11661)
* Incref heap-allocated types in PyObject_Init * Add documentation and porting notes to What's New
Diffstat (limited to 'Include/objimpl.h')
-rw-r--r--Include/objimpl.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index f475ed0..2337d8a 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -138,6 +138,9 @@ _PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
{
assert(op != NULL);
Py_TYPE(op) = typeobj;
+ if (PyType_GetFlags(typeobj) & Py_TPFLAGS_HEAPTYPE) {
+ Py_INCREF(typeobj);
+ }
_Py_NewReference(op);
return op;
}