Skip to content

Commit 42f868a

Browse files
committed
object.py raise TypeError on missing tp_new
1 parent 8dbc3a8 commit 42f868a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

graalpython/lib-graalpython/object.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def _get_new_arguments(obj):
7171

7272
def reduce_newobj(obj):
7373
cls = obj.__class__
74+
if not cls.__dict__.get('__new__', None):
75+
raise TypeError("cannot pickle '{}' object".format(cls.__name__))
76+
7477
args, kwargs = _get_new_arguments(obj)
7578
import_copyreg()
7679

@@ -92,7 +95,7 @@ def reduce_newobj(obj):
9295
except AttributeError:
9396
itemsize = getattr(type(obj), '__itemsize__', 0)
9497
if itemsize != 0:
95-
raise TypeError("cannot pickle '{}' object".format(type(obj).__name__))
98+
raise TypeError("cannot pickle '{}' object".format(cls.__name__))
9699

97100
state = getattr(obj, "__dict__", None)
98101
names = slotnames(cls) # not checking for list

0 commit comments

Comments
 (0)