Skip to content

Commit

Permalink
Fix import of pickle module on PYPY 3.8 (cloudpipe#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
schettino72 committed Dec 20, 2021
1 parent 5d89947 commit e61da59
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: [3.6, 3.7, 3.8, 3.9, "3.10-dev", "pypy3"]
python_version: [3.6, 3.7, 3.8, 3.9, "3.10-dev", "pypy-3.8"]
exclude:
# Do not test all minor versions on all platforms, especially if they
# are not the oldest/newest supported versions
Expand All @@ -41,7 +41,7 @@ jobs:
python_version: 3.8
# as of 4/02/2020, psutil won't build under PyPy + Windows
- os: windows-latest
python_version: "pypy3"
python_version: "pypy-3.8"
- os: macos-latest
python_version: 3.6
- os: macos-latest
Expand All @@ -51,7 +51,7 @@ jobs:
- os: macos-latest
# numpy triggers: RuntimeError: Polyfit sanity test emitted a
# warning
python_version: "pypy3"
python_version: "pypy-3.8"

runs-on: ${{ matrix.os }}

Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,9 @@
and `abc.abstractstaticmethod`.
([PR #450](https://github.com/cloudpipe/cloudpickle/pull/450))

- Fix import of pickle module on PYPY 3.8.
([issue #455](https://github.com/cloudpipe/cloudpickle/issues/455))

2.0.0
=====

Expand Down
5 changes: 1 addition & 4 deletions cloudpickle/cloudpickle.py
Expand Up @@ -44,7 +44,6 @@
import builtins
import dis
import opcode
import platform
import sys
import types
import weakref
Expand All @@ -53,7 +52,7 @@
import typing
import warnings

from .compat import pickle
from .compat import pickle, PYPY
from collections import OrderedDict
from typing import ClassVar, Generic, Union, Tuple, Callable
from pickle import _getattribute
Expand Down Expand Up @@ -92,8 +91,6 @@ def g():
_DYNAMIC_CLASS_TRACKER_BY_ID = weakref.WeakValueDictionary()
_DYNAMIC_CLASS_TRACKER_LOCK = threading.Lock()

PYPY = platform.python_implementation() == "PyPy"

builtin_code_type = None
if PYPY:
# builtin-code objects only exist in pypy
Expand Down
4 changes: 2 additions & 2 deletions cloudpickle/cloudpickle_fast.py
Expand Up @@ -25,14 +25,14 @@
from enum import Enum
from collections import ChainMap, OrderedDict

from .compat import pickle, Pickler
from .compat import pickle, Pickler, PYPY
from .cloudpickle import (
_extract_code_globals, _BUILTIN_TYPE_NAMES, DEFAULT_PROTOCOL,
_find_imported_submodules, _get_cell_contents, _should_pickle_by_reference,
_builtin_type, _get_or_create_tracker_id, _make_skeleton_class,
_make_skeleton_enum, _extract_class_dict, dynamic_subimport, subimport,
_typevar_reduce, _get_bases, _make_cell, _make_empty_cell, CellType,
_is_parametrized_type_hint, PYPY, cell_set,
_is_parametrized_type_hint, cell_set,
parametrized_type_hint_getinitargs, _create_parametrized_type_hint,
builtin_code_type,
_make_dict_keys, _make_dict_values, _make_dict_items,
Expand Down
4 changes: 3 additions & 1 deletion cloudpickle/compat.py
@@ -1,7 +1,9 @@
import sys
import platform

PYPY = platform.python_implementation() == "PyPy"

if sys.version_info < (3, 8):
if sys.version_info < (3, 8) or PYPY:
try:
import pickle5 as pickle # noqa: F401
from pickle5 import Pickler # noqa: F401
Expand Down

0 comments on commit e61da59

Please sign in to comment.