     
     log("Loading symbol '\(name)' from the Python library...")
     return unsafeBitCast(
-      dlsym(PythonLibrary.shared.pythonLibraryHandle, name),
+      loadSymbol(PythonLibrary.shared.pythonLibraryHandle, name),
       to: type
     )
   }

      }
    }
    
    let path = path.split(separator: libraryPathVersionCharacter)
      .joined(separator: versionString)
    return loadPythonLibrary(at: path)
  }
  
  static func loadPythonLibrary(at path: String) -> UnsafeMutableRawPointer? {
    log("Trying to load library at '\(path)'...")
    // Must be RTLD_GLOBAL because subsequent .so files from the imported python
    // modules may depend on this .so file.
    let pythonLibraryHandle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL)
    
    if pythonLibraryHandle != nil {
      log("Library at '\(path)' was sucessfully loaded.")

    var versionString: String {
      var versionString = String(major)
      if let minor = minor {
        versionString += "\(PythonVersion.versionSeparator)\(minor)"
      }
      return versionString
    }
