]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Use importlib.import_module. 441/head
authorBrian Wellington <bwelling@xbill.org>
Thu, 2 Apr 2020 16:06:21 +0000 (09:06 -0700)
committerBrian Wellington <bwelling@xbill.org>
Thu, 2 Apr 2020 16:06:21 +0000 (09:06 -0700)
Replace the open-coded import_module() with the one in importlib.

dns/rdata.py

index 136d92a93e5fde3142925fecc317d71391a82d3c..9354418d40c2d472f9a097a38937c461f5c86155 100644 (file)
@@ -17,6 +17,7 @@
 
 """DNS rdata."""
 
+from importlib import import_module
 from io import BytesIO
 import base64
 import binascii
@@ -28,11 +29,6 @@ import dns.rdatatype
 import dns.tokenizer
 import dns.wiredata
 
-try:
-    import threading as _threading
-except ImportError:
-    import dummy_threading as _threading
-
 _hex_chunksize = 32
 
 
@@ -323,18 +319,8 @@ class GenericRdata(Rdata):
 
 _rdata_modules = {}
 _module_prefix = 'dns.rdtypes'
-_import_lock = _threading.Lock()
 
 def get_rdata_class(rdclass, rdtype):
-
-    def import_module(name):
-        with _import_lock:
-            mod = __import__(name)
-            components = name.split('.')
-            for comp in components[1:]:
-                mod = getattr(mod, comp)
-            return mod
-
     mod = _rdata_modules.get((rdclass, rdtype))
     rdclass_text = dns.rdataclass.to_text(rdclass)
     rdtype_text = dns.rdatatype.to_text(rdtype)