Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #82: Avoid creating a side-effect in typing module. #337

Merged
merged 6 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
- Fix a bug affecting dynamic modules occuring with modified builtins
([issue #316](https://github.com/cloudpipe/cloudpickle/issues/316))

1.2.3
=====

- Fix a bug affecting cloudpickle when non-modules objects are added into
sys.modules
([PR #326](https://github.com/cloudpipe/cloudpickle/pull/326)).
Expand All @@ -23,6 +20,10 @@
https://docs.python.org/3/library/pickle.html#example
([issue #308](https://github.com/cloudpipe/cloudpickle/pull/308))

- Fix a side effect that would redefine `types.ClassTypes` as `type`
when importing cloudpickle.
([issue #337](https://github.com/cloudpipe/cloudpickle/pull/337))

1.2.2
=====

Expand Down
2 changes: 1 addition & 1 deletion cloudpickle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
if sys.version_info[:2] >= (3, 8):
from cloudpickle.cloudpickle_fast import CloudPickler, dumps, dump

__version__ = '1.2.3dev0'
__version__ = '1.3.0dev0'
4 changes: 2 additions & 2 deletions cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
PY3 = False
PY2 = True
else:
types.ClassType = type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's wild! I had never realized that cloudpickle would do that...

from pickle import _Pickler as Pickler
from io import BytesIO as StringIO
string_types = (str,)
Expand Down Expand Up @@ -889,7 +888,8 @@ def save_global(self, obj, name=None, pack=struct.pack):
Pickler.save_global(self, obj, name=name)

dispatch[type] = save_global
dispatch[types.ClassType] = save_global
if PY2:
dispatch[types.ClassType] = save_global

def save_instancemethod(self, obj):
# Memoization rarely is ever useful due to python bounding
Expand Down