Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian committed Apr 24, 2024
1 parent 18ca45c commit 82d5c5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/coredumpy/py_object_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def load_objects(cls, data):

@classmethod
def default_encode(cls, obj):
if cls.__module__ in ("builtins", "__main__"):
typename = type(obj).__qualname__
obj_type = type(obj)
if obj_type.__module__ in ("builtins", "__main__"):
typename = obj_type.__qualname__
else:
typename = f"{cls.__module__}.{type(obj).__qualname__}"
typename = f"{obj_type.__module__}.{obj_type.__qualname__}"

data = {"type": typename, "attrs": {}}
if isinstance(obj, (types.ModuleType,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_py_object_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def test_bool(self):
proxy = self.convert_object(obj)
self.assertEqual(proxy, True)

def test_builtins(self):
obj = object()
proxy = self.convert_object(obj)
self.assertEqual(proxy._coredumpy_type, "object")

def test_module(self):
import os
proxy = self.convert_object(os)
Expand Down

0 comments on commit 82d5c5d

Please sign in to comment.