mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
rejects builtin types with not defined __new__. Added tests for non-pickleable types.
This commit is contained in:
commit
609a2e17ad
7 changed files with 99 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
# For this purpose, the module-level "ET" symbol is temporarily
|
||||
# monkey-patched when running the "test_xml_etree_c" test suite.
|
||||
|
||||
import copy
|
||||
import html
|
||||
import io
|
||||
import operator
|
||||
|
|
@ -2082,6 +2083,19 @@ class ElementIterTest(unittest.TestCase):
|
|||
self.assertEqual(self._ilist(doc), all_tags)
|
||||
self.assertEqual(self._ilist(doc, '*'), all_tags)
|
||||
|
||||
def test_copy(self):
|
||||
a = ET.Element('a')
|
||||
it = a.iter()
|
||||
with self.assertRaises(TypeError):
|
||||
copy.copy(it)
|
||||
|
||||
def test_pickle(self):
|
||||
a = ET.Element('a')
|
||||
it = a.iter()
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.assertRaises((TypeError, pickle.PicklingError)):
|
||||
pickle.dumps(it, proto)
|
||||
|
||||
|
||||
class TreeBuilderTest(unittest.TestCase):
|
||||
sample1 = ('<!DOCTYPE html PUBLIC'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue