Skip to content

Commit 6ef7a32

Browse files
authored
Fix loading of private symbols within cimpl
1 parent 2dbfd66 commit 6ef7a32

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
try:
2-
from .sasl2_3.cimpl import *
3-
variant = "sasl2_3"
4-
except ImportError:
1+
import importlib
2+
3+
variant = None
4+
5+
for module_name in ("sasl2_3", "sasl2_2", "nodeps"):
56
try:
6-
from .sasl2_2.cimpl import *
7-
variant = "sasl2_2"
8-
except ImportError:
9-
from .nodeps.cimpl import *
10-
variant = "nodeps"
7+
module = importlib.import_module(f".{module_name}.cimpl", __package__)
8+
variant = module_name
9+
for name in dir(module):
10+
if not name.startswith("__"):
11+
globals()[name] = getattr(module, name)
12+
break
13+
except ModuleNotFoundError:
14+
pass
15+
16+
if variant is None:
17+
msg = "No valid native Python extension found"
18+
raise ImportError(msg)

0 commit comments

Comments
 (0)