Skip to content

Commit

Permalink
Fix getattr uses with invalid default values (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbell10 authored Jul 22, 2021
1 parent 4a31c65 commit 50eab92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
2.3.0 (in development)
======================

- Fixed an attribute error when using old versions of OpenBLAS or BLIS that are
missing version query functions.
https://github.com/joblib/threadpoolctl/pull/88


2.2.0 (2021-07-09)
Expand Down
12 changes: 8 additions & 4 deletions threadpoolctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,10 @@ class _OpenBLASModule(_Module):
def get_version(self):
# None means OpenBLAS is not loaded or version < 0.3.4, since OpenBLAS
# did not expose its version before that.
get_config = getattr(self._dynlib, "openblas_get_config",
lambda: None)
get_config = getattr(self._dynlib, "openblas_get_config", None)
if get_config is None:
return None

get_config.restype = ctypes.c_char_p
config = get_config().split()
if config[0] == b"OpenBLAS":
Expand Down Expand Up @@ -683,8 +685,10 @@ def get_architecture(self):
class _BLISModule(_Module):
"""Module class for BLIS"""
def get_version(self):
get_version_ = getattr(self._dynlib, "bli_info_get_version_str",
lambda: None)
get_version_ = getattr(self._dynlib, "bli_info_get_version_str", None)
if get_version_ is None:
return None

get_version_.restype = ctypes.c_char_p
return get_version_().decode("utf-8")

Expand Down

0 comments on commit 50eab92

Please sign in to comment.