Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-35810: Incref heap-allocated types in PyObject_Init#11661

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
encukou merged 10 commits intopython:masterfromeduardo-elizondo:incref-heaptypes
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Update structseq and whatsnew
  • Loading branch information
@eduardo-elizondo
eduardo-elizondo committedFeb 6, 2019
commit9b5ecd64f3a5d767a3a7a3e015ad561ab910bd76
14 changes: 14 additions & 0 deletionsDoc/whatsnew/3.8.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -347,6 +347,20 @@ Build and C API Changes

(Contributed by Antoine Pitrou in :issue:`32430`.)

* Heap-allocated Types will now incref through :c:func:`PyObject_Init` (and
its parallel macro PyObject_INIT) instead of :c:func:`PyType_GenericAlloc`.

All instance allocation C APIs that call
:c:func:`PyObject_Init` will incref the Type accordingly. This
includes: :c:func:`PyObject_New`, :c:func:`PyObject_NewVar`,
:c:func:`PyObject_GC_New`, :c:func:`PyObject_GC_NewVar`, and all their
corresponding macros.

To prevent leaks tp_dealloc has be updated to decref the Type if it's not
already doing so.

(Contributed by Eddie Elizondo in :issue:`35810`.)


Deprecated
==========
Expand Down
6 changes: 4 additions & 2 deletionsModules/_curses_panel.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -250,8 +250,10 @@ PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
static void
PyCursesPanel_Dealloc(PyCursesPanelObject *po)
{
PyObject *tp = (PyObject *) Py_TYPE(po);
PyObject *obj = (PyObject *) panel_userptr(po->pan);
PyObject *tp, *obj;

tp = (PyObject *) Py_TYPE(po);
obj = (PyObject *) panel_userptr(po->pan);
if (obj) {
(void)set_panel_userptr(po->pan, NULL);
Py_DECREF(obj);
Expand Down
5 changes: 5 additions & 0 deletionsObjects/structseq.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,12 +62,17 @@ static void
structseq_dealloc(PyStructSequence *obj)
{
Py_ssize_t i, size;
PyTypeObject *tp;

tp = (PyTypeObject *) Py_TYPE(obj);
size = REAL_SIZE(obj);
for (i = 0; i < size; ++i) {
Py_XDECREF(obj->ob_item[i]);
}
PyObject_GC_Del(obj);
if (PyType_GetFlags(tp) & Py_TPFLAGS_HEAPTYPE) {
Py_DECREF(tp);
}
}

/*[clinic input]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp