mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
direct: Fix errors in PythonUtil.detectLeaks() function (#955)
* Replaced removed choice() function with ternary expression * Add sanity check for _crashOnProactiveLeakDetect, don't crash by default Closes #955
This commit is contained in:
parent
913ab6669e
commit
86cfbc22b1
@ -94,12 +94,12 @@ class DirectObject:
|
|||||||
if hasattr(self, '_taskList'):
|
if hasattr(self, '_taskList'):
|
||||||
tasks = [task.name for task in self._taskList.values()]
|
tasks = [task.name for task in self._taskList.values()]
|
||||||
if len(events) or len(tasks):
|
if len(events) or len(tasks):
|
||||||
estr = choice(len(events), 'listening to events: %s' % events, '')
|
estr = ('listening to events: %s' % events if len(events) else '')
|
||||||
andStr = choice(len(events) and len(tasks), ' and ', '')
|
andStr = (' and ' if len(events) and len(tasks) else '')
|
||||||
tstr = choice(len(tasks), '%srunning tasks: %s' % (andStr, tasks), '')
|
tstr = ('%srunning tasks: %s' % (andStr, tasks) if len(tasks) else '')
|
||||||
notify = directNotify.newCategory('LeakDetect')
|
notify = directNotify.newCategory('LeakDetect')
|
||||||
func = choice(getRepository()._crashOnProactiveLeakDetect,
|
crash = getattr(getRepository(), '_crashOnProactiveLeakDetect', False)
|
||||||
self.notify.error, self.notify.warning)
|
func = (self.notify.error if crash else self.notify.warning)
|
||||||
func('destroyed %s instance is still %s%s' % (self.__class__.__name__, estr, tstr))
|
func('destroyed %s instance is still %s%s' % (self.__class__.__name__, estr, tstr))
|
||||||
|
|
||||||
#snake_case alias:
|
#snake_case alias:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user