Skip to content
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ master
- Ensure that unpickling a function defined in a dynamic module several times
sequentially does not reset the values of global variables.
([issue #187](https://github.com/cloudpipe/cloudpickle/issues/205))
- Restrict the ability to pickle annotations to python3.7+ ([issue #193](
https://github.com/cloudpipe/cloudpickle/issues/193) and [issue #196](https://github.com/cloudpipe/cloudpickle/issues/196))


0.5.6
Expand Down
2 changes: 1 addition & 1 deletion cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def save_function_tuple(self, func):
'name': func.__name__,
'doc': func.__doc__,
}
if hasattr(func, '__annotations__'):
if hasattr(func, '__annotations__') and sys.version_info >= (3, 7):
state['annotations'] = func.__annotations__
if hasattr(func, '__qualname__'):
state['qualname'] = func.__qualname__
Expand Down
4 changes: 3 additions & 1 deletion tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,9 @@ def g():

self.assertEqual(f2.__doc__, f.__doc__)

@unittest.skipIf(sys.version_info[0] < 3, "This syntax won't work on py2.")
@unittest.skipIf(sys.version_info < (3, 7),
"""This syntax won't work on py2 and pickling annotations
isn't supported for py36 and below.""")
def test_wraps_preserves_function_annotations(self):
from functools import wraps

Expand Down