Skip to content

Commit

Permalink
gh-92123: Convert _elementtree types to heap types (#99221)
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland authored Jan 20, 2023
1 parent 9109d46 commit 3847a6c
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 236 deletions.
20 changes: 20 additions & 0 deletions Lib/test/test_xml_etree_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ def __hash__(self):
r = e.get(X())
self.assertIsNone(r)

@support.cpython_only
def test_immutable_types(self):
root = cET.fromstring('<a></a>')
dataset = (
cET.Element,
cET.TreeBuilder,
cET.XMLParser,
type(root.iter()),
)
for tp in dataset:
with self.subTest(tp=tp):
with self.assertRaisesRegex(TypeError, "immutable"):
tp.foo = 1

@support.cpython_only
def test_disallow_instantiation(self):
root = cET.fromstring('<a></a>')
iter_type = type(root.iter())
support.check_disallow_instantiation(self, iter_type)


@unittest.skipUnless(cET, 'requires _elementtree')
class TestAliasWorking(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert :mod:`elementtree` types to heap types. Patch by Erlend E. Aasland.
Loading

0 comments on commit 3847a6c

Please sign in to comment.