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
18f018ca
Commit
18f018ca
authored
Dec 21, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28871: Fixed a crash when deallocate deep ElementTree.
parent
fb2ae15c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
Lib/test/test_xml_etree_c.py
Lib/test/test_xml_etree_c.py
+10
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_elementtree.c
Modules/_elementtree.c
+2
-0
No files found.
Lib/test/test_xml_etree_c.py
View file @
18f018ca
...
...
@@ -11,6 +11,7 @@ cET_alias = import_fresh_module('xml.etree.cElementTree',
fresh
=
[
'_elementtree'
,
'xml.etree'
])
@
unittest
.
skipUnless
(
cET
,
'requires _elementtree'
)
class
MiscTests
(
unittest
.
TestCase
):
# Issue #8651.
@
support
.
bigmemtest
(
size
=
support
.
_2G
+
100
,
memuse
=
1
,
dry_run
=
False
)
...
...
@@ -54,6 +55,15 @@ class MiscTests(unittest.TestCase):
del
element
.
attrib
self
.
assertEqual
(
element
.
attrib
,
{
'A'
:
'B'
,
'C'
:
'D'
})
def
test_trashcan
(
self
):
# If this test fails, it will most likely die via segfault.
e
=
root
=
cET
.
Element
(
'root'
)
for
i
in
range
(
200000
):
e
=
cET
.
SubElement
(
e
,
'x'
)
del
e
del
root
support
.
gc_collect
()
@
unittest
.
skipUnless
(
cET
,
'requires _elementtree'
)
class
TestAliasWorking
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
18f018ca
...
...
@@ -138,6 +138,8 @@ Core and Builtins
Library
-------
- Issue #28871: Fixed a crash when deallocate deep ElementTree.
- Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and
WeakValueDictionary.pop() when a GC collection happens in another
thread.
...
...
Modules/_elementtree.c
View file @
18f018ca
...
...
@@ -652,6 +652,7 @@ static void
element_dealloc
(
ElementObject
*
self
)
{
PyObject_GC_UnTrack
(
self
);
Py_TRASHCAN_SAFE_BEGIN
(
self
)
if
(
self
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
...
...
@@ -662,6 +663,7 @@ element_dealloc(ElementObject* self)
RELEASE
(
sizeof
(
ElementObject
),
"destroy element"
);
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
Py_TRASHCAN_SAFE_END
(
self
)
}
/* -------------------------------------------------------------------- */
...
...
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