Skip to content

Commit 94ec937

Browse files
committed
more robust repr handling
1 parent 48a305c commit 94ec937

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cuda_py/cuda/py/_memoryview.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ cdef class GPUMemoryView:
2929
return (f"GPUMemoryView(ptr={self.ptr},\n"
3030
+ f" shape={self.shape},\n"
3131
+ f" strides={self.strides},\n"
32-
+ f" dtype={self.dtype.__name__},\n"
32+
+ f" dtype={get_simple_repr(self.dtype)},\n"
3333
+ f" device_id={self.device_id},\n"
3434
+ f" device_accessible={self.device_accessible},\n"
3535
+ f" readonly={self.readonly},\n"
3636
+ f" obj={get_simple_repr(self.obj)})")
3737

3838

3939
cdef str get_simple_repr(obj):
40-
cdef object obj_class = obj.__class__
40+
cdef object obj_class
4141
cdef str obj_repr
42+
if isinstance(obj, type):
43+
obj_class = obj
44+
else:
45+
obj_class = obj.__class__
4246
if obj_class.__module__ in (None, "builtins"):
4347
obj_repr = obj_class.__name__
4448
else:

0 commit comments

Comments
 (0)