| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Modify ``PyObject_Init`` to correctly increase the refcount of heap- | ||
| allocated Type objects. Also fix the refcounts of the heap-allocated types | ||
| that were either doing this manually or not decreasing the type's refcount | ||
| in tp_dealloc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -229,6 +229,9 @@ PyObject_Init(PyObject *op, PyTypeObject *tp) | |
| return PyErr_NoMemory(); | ||
| /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ | ||
| Py_TYPE(op) = tp; | ||
| if (PyType_GetFlags(tp) & Py_TPFLAGS_HEAPTYPE) { | ||
| Py_INCREF(tp); | ||
| } | ||
| _Py_NewReference(op); | ||
| return op; | ||
| } | ||
| Expand All | @@ -239,9 +242,8 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size) | |
| if (op == NULL) | ||
| return (PyVarObject *) PyErr_NoMemory(); | ||
| /* Any changes should be reflected in PyObject_INIT_VAR */ | ||
| op->ob_size = size; | ||
| Py_TYPE(op) = tp; | ||
| _Py_NewReference((PyObject *)op); | ||
| Py_SIZE(op) = size; | ||
| PyObject_Init((PyObject *)op, tp); | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityShouldn't this just call _PyObject_INIT() ?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOr, actually, shouldn't PyObject_Init() just call _PyObject_INIT() ? Duplicating that code across two files seems unnecessary, maybe even a bit error prone.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityPyObject_Init is defined in the same file, so the compiler should have everything it needs to inline as it sees fit. As for code duplication, that's a valid point, but I'd call that out of scope for this PR. Let's keep orthogonal issues revertable separately.
Sorry, something went wrong.
scoder and eduardo-elizondo reacted with thumbs up emoji
All reactions
|
||
| return op; | ||
| } | ||
|
|
||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIn Cython, we normally use the exact alpha/beta version where the change was introduced (to support testing during the CPython release cycle), but we obviously don't know that yet.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe example is not really written for projects with Cython's level of involvement. Most projects will only test against a nightly build or the latest alpha/beta (if even that). The few others should know to adjust the example. We don't explicitly tell you to rename foo_new, either :)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.