mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -1,4 +1,6 @@
|
|||
import copy
|
||||
import gc
|
||||
import pickle
|
||||
import sys
|
||||
import unittest
|
||||
import warnings
|
||||
|
@ -111,6 +113,21 @@ class GeneratorTest(unittest.TestCase):
|
|||
self.assertEqual(gen.__qualname__,
|
||||
"GeneratorTest.test_name.<locals>.<genexpr>")
|
||||
|
||||
def test_copy(self):
|
||||
def f():
|
||||
yield 1
|
||||
g = f()
|
||||
with self.assertRaises(TypeError):
|
||||
copy.copy(g)
|
||||
|
||||
def test_pickle(self):
|
||||
def f():
|
||||
yield 1
|
||||
g = f()
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.assertRaises((TypeError, pickle.PicklingError)):
|
||||
pickle.dumps(g, proto)
|
||||
|
||||
|
||||
class ExceptionTest(unittest.TestCase):
|
||||
# Tests for the issue #23353: check that the currently handled exception
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue