Skip to content

Commit f305a7b

Browse files
committed
bpo-34816: Raise AttributeError if loading fails in ctypes.LibraryLoader.__get_attr__
1 parent 35715d1 commit f305a7b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/ctypes/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,10 @@ def __init__(self, dlltype):
441441
def __getattr__(self, name):
442442
if name[0] == '_':
443443
raise AttributeError(name)
444-
dll = self._dlltype(name)
444+
try:
445+
dll = self._dlltype(name)
446+
except OSError:
447+
raise AttributeError(name)
445448
setattr(self, name, dll)
446449
return dll
447450

0 commit comments

Comments
 (0)