mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
bpo-37210: Fix pure Python pickle when _pickle is unavailable (GH-14016)
Allow pure Python implementation of pickle to work even when the C _pickle module is unavailable. Fix test_pickle when _pickle is missing: declare PyPicklerHookTests outside "if has_c_implementation:" block.
This commit is contained in:
parent
6f75c87375
commit
63ab4ba07b
3 changed files with 41 additions and 32 deletions
|
|
@ -203,6 +203,13 @@ class PyChainDispatchTableTests(AbstractDispatchTableTests):
|
|||
return collections.ChainMap({}, pickle.dispatch_table)
|
||||
|
||||
|
||||
class PyPicklerHookTests(AbstractHookTests):
|
||||
class CustomPyPicklerClass(pickle._Pickler,
|
||||
AbstractCustomPicklerClass):
|
||||
pass
|
||||
pickler_class = CustomPyPicklerClass
|
||||
|
||||
|
||||
if has_c_implementation:
|
||||
class CPickleTests(AbstractPickleModuleTests):
|
||||
from _pickle import dump, dumps, load, loads, Pickler, Unpickler
|
||||
|
|
@ -255,12 +262,6 @@ if has_c_implementation:
|
|||
def get_dispatch_table(self):
|
||||
return collections.ChainMap({}, pickle.dispatch_table)
|
||||
|
||||
class PyPicklerHookTests(AbstractHookTests):
|
||||
class CustomPyPicklerClass(pickle._Pickler,
|
||||
AbstractCustomPicklerClass):
|
||||
pass
|
||||
pickler_class = CustomPyPicklerClass
|
||||
|
||||
class CPicklerHookTests(AbstractHookTests):
|
||||
class CustomCPicklerClass(_pickle.Pickler, AbstractCustomPicklerClass):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue