Skip to content

Commit a7190c4

Browse files
authored
Catch NoneType __getstate__() in tests.helper.py
1 parent 121b1d7 commit a7190c4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎astropy/tests/helper.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ def generic_recursive_equality_test(a, b, class_history):
418418
else:
419419
# NOTE: The call may need to be adapted if other objects implementing a __getstate__
420420
# with required argument(s) are passed to this function.
421-
dict_a = a.__getstate__(a) if inspect.isclass(a) else a.__getstate__()
421+
# For a class that has no instance __dict__ and no __slots__, the default state is None
422+
dict_a = a.__getstate__(a) if inspect.isclass(a) else a.__getstate__() or dict()
422423
dict_b = b.__dict__
423424
for key in dict_a:
424425
assert key in dict_b, f"Did not pickle {key}"

0 commit comments

Comments
 (0)