Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d2a75c67
Commit
d2a75c67
authored
Dec 18, 2018
by
Serhiy Storchaka
Committed by
GitHub
Dec 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35502: Fix reference leaks in ElementTree.TreeBuilder. (GH-11170)
parent
60875db2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
Lib/test/test_xml_etree_c.py
Lib/test/test_xml_etree_c.py
+21
-0
Misc/NEWS.d/next/Library/2018-12-14-23-56-48.bpo-35502.gLHuFS.rst
...S.d/next/Library/2018-12-14-23-56-48.bpo-35502.gLHuFS.rst
+3
-0
Modules/_elementtree.c
Modules/_elementtree.c
+5
-0
No files found.
Lib/test/test_xml_etree_c.py
View file @
d2a75c67
# xml.etree test for cElementTree
import
io
import
struct
from
test
import
support
from
test.support
import
import_fresh_module
...
...
@@ -133,6 +134,26 @@ class MiscTests(unittest.TestCase):
self
.
assertEqual
(
len
(
elem
),
1
)
self
.
assertEqual
(
elem
[
0
].
tag
,
'child'
)
def
test_iterparse_leaks
(
self
):
# Test reference leaks in TreeBuilder (issue #35502).
# The test is written to be executed in the hunting reference leaks
# mode.
XML
=
'<a></a></b>'
parser
=
cET
.
iterparse
(
io
.
StringIO
(
XML
))
next
(
parser
)
del
parser
support
.
gc_collect
()
def
test_xmlpullparser_leaks
(
self
):
# Test reference leaks in TreeBuilder (issue #35502).
# The test is written to be executed in the hunting reference leaks
# mode.
XML
=
'<a></a></b>'
parser
=
cET
.
XMLPullParser
()
parser
.
feed
(
XML
)
del
parser
support
.
gc_collect
()
@
unittest
.
skipUnless
(
cET
,
'requires _elementtree'
)
class
TestAliasWorking
(
unittest
.
TestCase
):
...
...
Misc/NEWS.d/next/Library/2018-12-14-23-56-48.bpo-35502.gLHuFS.rst
0 → 100644
View file @
d2a75c67
Fixed reference leaks in :class:`xml.etree.ElementTree.TreeBuilder` in case
of unfinished building of the tree (in particular when an error was raised
during parsing XML).
Modules/_elementtree.c
View file @
d2a75c67
...
...
@@ -2447,6 +2447,11 @@ _elementtree_TreeBuilder___init___impl(TreeBuilderObject *self,
static
int
treebuilder_gc_traverse
(
TreeBuilderObject
*
self
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
self
->
end_ns_event_obj
);
Py_VISIT
(
self
->
start_ns_event_obj
);
Py_VISIT
(
self
->
end_event_obj
);
Py_VISIT
(
self
->
start_event_obj
);
Py_VISIT
(
self
->
events_append
);
Py_VISIT
(
self
->
root
);
Py_VISIT
(
self
->
this
);
Py_VISIT
(
self
->
last
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment