Skip to content

Commit

Permalink
Apply 'Incorrect pickles for subclasses of generic classes ray-projec…
Browse files Browse the repository at this point in the history
…t#448' from cloudpickle (ray-project#22553)

Co-authored-by: Chen Shen <scv119@gmail.com>
  • Loading branch information
2 people authored and edoakes committed Apr 7, 2022
1 parent 476ffee commit 43c7ea2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/ray/cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,13 @@ def _typevar_reduce(obj):


def _get_bases(typ):
if hasattr(typ, "__orig_bases__"):
if '__orig_bases__' in getattr(typ, '__dict__', {}):
# For generic types (see PEP 560)
bases_attr = "__orig_bases__"
# Note that simply checking `hasattr(typ, '__orig_bases__')` is not
# correct. Subclasses of a fully-parameterized generic class does not
# have `__orig_bases__` defined, but `hasattr(typ, '__orig_bases__')`
# will return True because it's defined in the base class.
bases_attr = '__orig_bases__'
else:
# For regular class objects
bases_attr = "__bases__"
Expand Down

0 comments on commit 43c7ea2

Please sign in to comment.