Remove unnecessary try-finally blocks

This commit is contained in:
taras 2024-09-11 00:12:46 +02:00
parent 50497f9cc1
commit 54ac4f5947
1 changed files with 9 additions and 15 deletions

View File

@ -96,39 +96,33 @@ cdef inline run_in_context(context, method):
# certain circumstances, inlined context.run() will not hold a reference to # certain circumstances, inlined context.run() will not hold a reference to
# the given method instance, which - if deallocated - will cause segfault. # the given method instance, which - if deallocated - will cause segfault.
# See also: edgedb/edgedb#2222 # See also: edgedb/edgedb#2222
Context_Enter(context)
Py_INCREF(method) Py_INCREF(method)
try: try:
Context_Enter(context) return method()
try:
return method()
finally:
Context_Exit(context)
finally: finally:
Py_DECREF(method) Py_DECREF(method)
Context_Exit(context)
cdef inline run_in_context1(context, method, arg): cdef inline run_in_context1(context, method, arg):
Context_Enter(context)
Py_INCREF(method) Py_INCREF(method)
try: try:
Context_Enter(context) return method(arg)
try:
return method(arg)
finally:
Context_Exit(context)
finally: finally:
Py_DECREF(method) Py_DECREF(method)
Context_Exit(context)
cdef inline run_in_context2(context, method, arg1, arg2): cdef inline run_in_context2(context, method, arg1, arg2):
Context_Enter(context)
Py_INCREF(method) Py_INCREF(method)
try: try:
Context_Enter(context) return method(arg1, arg2)
try:
return method(arg1, arg2)
finally:
Context_Exit(context)
finally: finally:
Py_DECREF(method) Py_DECREF(method)
Context_Exit(context)
# Used for deprecation and removal of `loop.create_datagram_endpoint()`'s # Used for deprecation and removal of `loop.create_datagram_endpoint()`'s