File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,12 @@ def test_immutable_types(self):
195
195
with self .assertRaisesRegex (TypeError , "immutable" ):
196
196
tp .foo = 1
197
197
198
+ @support .cpython_only
199
+ def test_disallow_instantiation (self ):
200
+ root = cET .fromstring ('<a></a>' )
201
+ iter_type = type (root .iter ())
202
+ support .check_disallow_instantiation (self , iter_type )
203
+
198
204
199
205
@unittest .skipUnless (cET , 'requires _elementtree' )
200
206
class TestAliasWorking (unittest .TestCase ):
Original file line number Diff line number Diff line change @@ -2194,7 +2194,7 @@ static PyType_Spec elementiter_spec = {
2194
2194
.name = "_elementtree._element_iterator" ,
2195
2195
.basicsize = sizeof (ElementIterObject ),
2196
2196
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
2197
- Py_TPFLAGS_IMMUTABLETYPE ),
2197
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION ),
2198
2198
.slots = elementiter_slots ,
2199
2199
};
2200
2200
You can’t perform that action at this time.
0 commit comments