Browse Source

added safeRepr

Darren Ranalli 19 years ago
parent
commit
8fb0f4306c
1 changed files with 6 additions and 0 deletions
  1. 6 0
      direct/src/showbase/PythonUtil.py

+ 6 - 0
direct/src/showbase/PythonUtil.py

@@ -1986,6 +1986,12 @@ def gcDebugOn():
     import gc
     return (gc.get_debug() & gc.DEBUG_SAVEALL) == gc.DEBUG_SAVEALL
 
+def safeRepr(obj):
+    try:
+        return repr(obj)
+    except:
+        return '<** FAILED REPR OF %s **>' % obj.__class__.__name__
+
 class ScratchPad:
     """empty class to stick values onto"""
     def __init__(self, **kArgs):