Kaynağa Gözat

Update py_object.c

blueloveTH 1 ay önce
ebeveyn
işleme
27fde79de6
1 değiştirilmiş dosya ile 5 ekleme ve 2 silme
  1. 5 2
      src/bindings/py_object.c

+ 5 - 2
src/bindings/py_object.c

@@ -36,10 +36,13 @@ static bool object__ne__(int argc, py_Ref argv) {
 
 
 static bool object__repr__(int argc, py_Ref argv) {
 static bool object__repr__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     PY_CHECK_ARGC(1);
-    assert(argv->is_ptr);
     c11_sbuf buf;
     c11_sbuf buf;
     c11_sbuf__ctor(&buf);
     c11_sbuf__ctor(&buf);
-    pk_sprintf(&buf, "<%t object at %p>", argv->type, argv->_obj);
+    if(argv->is_ptr) {
+        pk_sprintf(&buf, "<%t object at %p>", argv->type, argv->_obj);
+    } else {
+        pk_sprintf(&buf, "<%t trivial object>", argv->type);
+    }
     c11_sbuf__py_submit(&buf, py_retval());
     c11_sbuf__py_submit(&buf, py_retval());
     return true;
     return true;
 }
 }