Skip to content

Commit d5ba1b3

Browse files
jeffdavcompnerd
authored andcommitted
Use dlerror() when dlopen() fails.
1 parent 6fee761 commit d5ba1b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

PythonKit/PythonLibrary.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ extension PythonLibrary {
205205
// Must be RTLD_GLOBAL because subsequent .so files from the imported python
206206
// modules may depend on this .so file.
207207
let pythonLibraryHandle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL)
208+
if pythonLibraryHandle == nil {
209+
self.log("Failed to load library at '\(path)'.")
210+
if let errorCString = dlerror() {
211+
let errorString = String(cString: errorCString)
212+
self.log("Reason for failure: \(errorString)")
213+
}
214+
}
208215
#endif
209216

210217
if pythonLibraryHandle != nil {

0 commit comments

Comments
 (0)