From d89da168bbe1a3784a12c0a7b941aec69ecda94a Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 9 Apr 2019 12:51:39 +0200 Subject: [PATCH] PythonUtil: fix use of types.InstanceType in Python 3 in itype() Really, though, don't use this function. It does not consider new-style classes, is not consistent in its return values and it seems to do nothing that repr(type(x)) doesn't do. --- direct/src/showbase/PythonUtil.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 721a67453e..2370742957 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -1652,17 +1652,15 @@ def itype(obj): # version of type that gives more complete information about instance types global dtoolSuperBase t = type(obj) - if t is types.InstanceType: - return '%s of >' % (repr(types.InstanceType)[:-1], - str(obj.__class__)) + if sys.version_info < (3, 0) and t is types.InstanceType: + return ">" % (obj.__class__) else: # C++ object instances appear to be types via type() # check if this is a C++ object if dtoolSuperBase is None: _getDtoolSuperBase() if isinstance(obj, dtoolSuperBase): - return '%s of %s>' % (repr(types.InstanceType)[:-1], - str(obj.__class__)) + return "" % (obj.__class__) return t def deeptype(obj, maxLen=100, _visitedIds=None):