Skip to content

Commit

Permalink
compat: Import Pickler from "pickle" instead of "_pickle"
Browse files Browse the repository at this point in the history
The latter is an implementation detail (see [0]),
and the docs instruct users to "always import the standard version"[0].
Moreover, "pickle.Pickler" is the same as "_pickle.Pickler",
for all recent CPython releases (tested 3.6->3.9).

[0] https://docs.python.org/3.1/whatsnew/3.0.html#library-changes

Fixes: #458

Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
  • Loading branch information
jvesely committed May 18, 2022
1 parent f758eb3 commit 9c64b6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cloudpickle/compat.py
Expand Up @@ -7,7 +7,7 @@
from pickle5 import Pickler # noqa: F401
except ImportError:
import pickle # noqa: F401
from pickle import _Pickler as Pickler # noqa: F401
from pickle import Pickler as Pickler # noqa: F401
else:
import pickle # noqa: F401
from _pickle import Pickler # noqa: F401
from pickle import Pickler # noqa: F401

0 comments on commit 9c64b6f

Please sign in to comment.