Skip to content

Commit

Permalink
Remove unnecessary try-finally blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Sep 10, 2024
1 parent 50497f9 commit 0701321
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,33 @@ cdef inline run_in_context(context, method):
# certain circumstances, inlined context.run() will not hold a reference to
# the given method instance, which - if deallocated - will cause segfault.
# See also: edgedb/edgedb#2222
Context_Enter(context)
Py_INCREF(method)
try:
Context_Enter(context)
try:
return method()
finally:
Context_Exit(context)
return method()
finally:
Py_DECREF(method)
Context_Exit(context)


cdef inline run_in_context1(context, method, arg):
Context_Enter(context)
Py_INCREF(method)
try:
Context_Enter(context)
try:
return method(arg)
finally:
Context_Exit(context)
return method(arg)
finally:
Py_DECREF(method)
Context_Exit(context)


cdef inline run_in_context2(context, method, arg1, arg2):
Context_Enter(context)
Py_INCREF(method)
try:
Context_Enter(context)
try:
return method(arg1, arg2)
finally:
Context_Exit(context)
return method(arg1, arg2)
finally:
Py_DECREF(method)
Context_Exit(context)


# Used for deprecation and removal of `loop.create_datagram_endpoint()`'s
Expand Down

0 comments on commit 0701321

Please sign in to comment.