Fix assert when 'pp_int' object has no attribute 'custom_print_str' (#7507)

Fix assert `'pp_int' object has no attribute 'custom_print_str'` when
tracking deepspeed module with some track debug tools like
[objwatch](https://github.com/aeeeeeep/objwatch)

```python3
    import objwatch
    objwatch.watch(targets=[deepspeed], framework="torch.distributed", indexes=[0,], with_locals=True)
```

Signed-off-by: aeeeeeep <aeeeeeep@proton.me>
This commit is contained in:
aeeeeeep
2025-08-25 22:57:08 +08:00
committed by GitHub
parent d9cb78683e
commit 38d1a9eb64

View File

@ -137,7 +137,7 @@ class pp_int(int):
return inst return inst
def __repr__(self): def __repr__(self):
if self.custom_print_str: if hasattr(self, "custom_print_str") and self.custom_print_str:
return self.custom_print_str return self.custom_print_str
return f"{self.real:,}" return f"{self.real:,}"