We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 85a99f8 + 5f4d205 commit 4b923bbCopy full SHA for 4b923bb
1 file changed
tests/unit/cython/utils.py
@@ -14,10 +14,6 @@
14
15
from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY
16
17
-if HAVE_CYTHON:
18
- import pyximport
19
- pyximport.install()
20
-
21
try:
22
import unittest2 as unittest
23
except ImportError:
@@ -28,12 +24,12 @@ def cyimport(import_path):
28
24
Import a Cython module if available, otherwise return None
29
25
(and skip any relevant tests).
30
26
"""
31
- try:
32
- return __import__(import_path, fromlist=[True])
33
- except ImportError:
34
- if HAVE_CYTHON:
35
- raise
36
- return None
27
+ if HAVE_CYTHON:
+ import pyximport
+ py_importer, pyx_importer = pyximport.install()
+ mod = __import__(import_path, fromlist=[True])
+ pyximport.uninstall(py_importer, pyx_importer)
+ return mod
37
38
39
# @cythontest
0 commit comments