diff --git a/CHANGES.md b/CHANGES.md index 790424cf4..d6a0aa988 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ 1.5.1 (in development) ====================== +- `cloudpickle`'s pickle.Pickler subclass (currently defined as + `cloudpickle.cloudpickle_fast.CloudPickler`) can and should now be accessed + as `cloudpickle.Pickler`. This is the only officially supported way of + accessing it. + ([issue #366](https://github.com/cloudpipe/cloudpickle/issues/366)) + 1.5.0 ===== diff --git a/cloudpickle/__init__.py b/cloudpickle/__init__.py index 16d82e347..9fe132460 100644 --- a/cloudpickle/__init__.py +++ b/cloudpickle/__init__.py @@ -4,4 +4,8 @@ from cloudpickle.cloudpickle import * # noqa from cloudpickle.cloudpickle_fast import CloudPickler, dumps, dump # noqa +# Conform to the convention used by python serialization libraries, which +# expose their Pickler subclass at top-level under the "Pickler" name. +Pickler = CloudPickler + __version__ = '1.5.1dev0' diff --git a/tests/cloudpickle_test.py b/tests/cloudpickle_test.py index 634d70a5a..a456b6372 100644 --- a/tests/cloudpickle_test.py +++ b/tests/cloudpickle_test.py @@ -2342,5 +2342,12 @@ class C(typing.Generic[T]): return types_to_test +def test_module_level_pickler(): + # #366: cloudpickle should expose its pickle.Pickler subclass as + # cloudpickle.Pickler + assert hasattr(cloudpickle, "Pickler") + assert cloudpickle.Pickler is cloudpickle.CloudPickler + + if __name__ == '__main__': unittest.main()