| 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 |
|---|---|---|
| Expand Up | @@ -2431,7 +2431,7 @@ treebuilder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
| t->element_factory = NULL; | ||
| t->comment_factory = NULL; | ||
| t->pi_factory = NULL; | ||
| t->stack = PyList_New(20); | ||
| t->stack = PyList_New(0); | ||
| if (!t->stack) { | ||
| Py_DECREF(t->this); | ||
| Py_DECREF(t->last); | ||
| Expand Down Expand Up | @@ -2856,9 +2856,9 @@ treebuilder_handle_end(TreeBuilderObject* self, PyObject* tag) | |
|
|
||
| item = self->last; | ||
| self->last = Py_NewRef(self->this); | ||
| Py_XSETREF(self->last_for_tail, self->last); | ||
| Py_XSETREF(self->last_for_tail, Py_NewRef(self->last)); | ||
|
Comment thread
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 QualityThis is unrelated. If rewrite this code to be more explicit or safe, I would write something like PyObject *last = self->last;
PyObject *last_for_tail = self->last_for_tail;
PyObject *this = self->this;
self->index--;
self->this = Py_NewRef(PyList_GET_ITEM(self->stack, self->index));
self->last = Py_NewRef(this);
self->last_for_tail = Py_NewRef(this);
Py_DECREF(last);
Py_XDECREF(last_for_tail);
if (treebuilder_append_event(self, self->end_event_obj, this) < 0) {
Py_DECREF(this);
return NULL;
}
return this;But we should also look a the other ends -- how these attributes are set in other code in this file. This is a separate issue.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
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 QualityI wrote #146167 which uses your suggestion.
Sorry, something went wrong.
All reactions
|
||
| self->index--; | ||
| self->this = Py_NewRef(PyList_GET_ITEM(self->stack, self->index)); | ||
| Py_SETREF(self->this, Py_NewRef(PyList_GET_ITEM(self->stack, self->index))); | ||
| Py_DECREF(item); | ||
|
|
||
| if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) | ||
| 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 QualityThis can have performance impact.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.