Skip to content

Commit 32eb34d

Browse files
committed
Move handle check to beginning to avoid unnecessary computation
1 parent d8b9ed3 commit 32eb34d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/ctypes/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ def _load_library(self, name, mode, handle, winmode):
440440

441441
else:
442442
def _load_library(self, name, mode, handle, winmode):
443+
if handle is not None:
444+
self._name = name
445+
return handle
443446
# If the filename that has been provided is an iOS/tvOS/watchOS
444447
# .fwork file, dereference the location to the true origin of the
445448
# binary.
@@ -458,8 +461,6 @@ def _load_library(self, name, mode, handle, winmode):
458461
if name and name.endswith(")") and ".a(" in name:
459462
mode |= _os.RTLD_MEMBER | _os.RTLD_NOW
460463
self._name = name
461-
if handle is not None:
462-
return handle
463464
return _dlopen(name, mode)
464465

465466
def __repr__(self):

0 commit comments

Comments
 (0)