Skip to content

Commit 86cfbc2

Browse files
fireclawthefoxrdb
authored andcommitted
direct: Fix errors in PythonUtil.detectLeaks() function (panda3d#955)
* Replaced removed choice() function with ternary expression * Add sanity check for _crashOnProactiveLeakDetect, don't crash by default Closes panda3d#955
1 parent 913ab66 commit 86cfbc2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

direct/src/showbase/DirectObject.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ def detectLeaks(self):
9494
if hasattr(self, '_taskList'):
9595
tasks = [task.name for task in self._taskList.values()]
9696
if len(events) or len(tasks):
97-
estr = choice(len(events), 'listening to events: %s' % events, '')
98-
andStr = choice(len(events) and len(tasks), ' and ', '')
99-
tstr = choice(len(tasks), '%srunning tasks: %s' % (andStr, tasks), '')
97+
estr = ('listening to events: %s' % events if len(events) else '')
98+
andStr = (' and ' if len(events) and len(tasks) else '')
99+
tstr = ('%srunning tasks: %s' % (andStr, tasks) if len(tasks) else '')
100100
notify = directNotify.newCategory('LeakDetect')
101-
func = choice(getRepository()._crashOnProactiveLeakDetect,
102-
self.notify.error, self.notify.warning)
101+
crash = getattr(getRepository(), '_crashOnProactiveLeakDetect', False)
102+
func = (self.notify.error if crash else self.notify.warning)
103103
func('destroyed %s instance is still %s%s' % (self.__class__.__name__, estr, tstr))
104104

105105
#snake_case alias:

0 commit comments

Comments
 (0)