1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Description: Fix greendns for dnspython 2.3.0+
dnspython added more type annotations in 2.3.0 -- because of how we
reimport the package piece by piece, though, not all of the types would
be available during reimport, leading to AttributeErrors like
.
module 'dns.rdtypes' has no attribute 'ANY'
.
Now, do all of our rdtypes special-handling *first*, before reimporting
any other submodules.
Author: Tim Burke <tim.burke@gmail.com>
Date: Tue, 17 Jan 2023 12:38:29 -0800
Origin: upstream, https://github.com/eventlet/eventlet/commit/333ee08cd4342de70664bb678cdaa361b0dc318b.patch
Last-Update: 2023-01-24
diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py
index b2f77ab4f..6b5a6cb72 100644
--- a/eventlet/support/greendns.py
+++ b/eventlet/support/greendns.py
@@ -62,8 +62,9 @@ def import_patched(module_name):
dns = import_patched('dns')
-for pkg in dns.__all__:
- setattr(dns, pkg, import_patched('dns.' + pkg))
+
+# Handle rdtypes separately; we need fully it available as we patch the rest
+dns.rdtypes = import_patched('dns.rdtypes')
dns.rdtypes.__all__.extend(['dnskeybase', 'dsbase', 'txtbase'])
for pkg in dns.rdtypes.__all__:
setattr(dns.rdtypes, pkg, import_patched('dns.rdtypes.' + pkg))
@@ -71,6 +72,11 @@ def import_patched(module_name):
setattr(dns.rdtypes.IN, pkg, import_patched('dns.rdtypes.IN.' + pkg))
for pkg in dns.rdtypes.ANY.__all__:
setattr(dns.rdtypes.ANY, pkg, import_patched('dns.rdtypes.ANY.' + pkg))
+
+for pkg in dns.__all__:
+ if pkg == 'rdtypes':
+ continue
+ setattr(dns, pkg, import_patched('dns.' + pkg))
del import_patched
|