Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f8bfc9 commit 77526f0Copy full SHA for 77526f0
1 file changed
Lib/test/test_hashlib.py
@@ -9,6 +9,7 @@
9
import array
10
from binascii import unhexlify
11
import hashlib
12
+import importlib
13
import itertools
14
import os
15
import sys
@@ -83,11 +84,11 @@ class HashLibTestCase(unittest.TestCase):
83
84
def _conditional_import_module(self, module_name):
85
"""Import a module and return a reference to it or None on failure."""
86
try:
- exec('import '+module_name)
87
- except ImportError as error:
+ return importlib.import_module(module_name)
88
+ except ModuleNotFoundError as error:
89
if self._warn_on_extension_import:
90
warnings.warn('Did a C extension fail to compile? %s' % error)
- return locals().get(module_name)
91
+ return None
92
93
def __init__(self, *args, **kwargs):
94
algorithms = set()
0 commit comments