Skip to content

Commit f132a1d

Browse files
committed
remove try/except from grab/ungrab
1 parent b0ceefe commit f132a1d

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

kivy/input/motionevent.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,15 @@ def on_touch_up(self, touch):
322322
raise Exception('Grab works only for Touch MotionEvents.')
323323
if self.grab_exclusive_class is not None:
324324
raise Exception('Cannot grab the touch, touch is exclusive')
325-
try:
326-
class_instance = weakref.ref(class_instance)
327-
except TypeError:
328-
# handle weakproxy objects which cannot be weakref'd
329-
class_instance = weakref.ref(class_instance.__self__)
325+
class_instance = weakref.ref(class_instance.__self__)
330326
if exclusive:
331327
self.grab_exclusive_class = class_instance
332328
self.grab_list.append(class_instance)
333329

334330
def ungrab(self, class_instance):
335331
'''Ungrab a previously grabbed touch
336332
'''
337-
try:
338-
class_instance = weakref.ref(class_instance)
339-
except TypeError:
340-
# handle weakproxy objects which cannot be weakref'd
341-
class_instance = weakref.ref(class_instance.__self__)
333+
class_instance = weakref.ref(class_instance.__self__)
342334
if self.grab_exclusive_class == class_instance:
343335
self.grab_exclusive_class = None
344336
if class_instance in self.grab_list:

0 commit comments

Comments
 (0)