def _patch_dns(): top = import_patched('dns') for pkg in ('dns', 'dns.rdtypes', 'dns.rdtypes.IN', 'dns.rdtypes.ANY'): mod = import_patched(pkg) for name in mod.__all__: setattr(mod, name, import_patched(pkg + '.' + name)) return top
def _patch_dns(): import platform result = platform.architecture() orig_arch = platform.architecture def arch(*args, **kwargs): if not args and not kwargs: return result return orig_arch(*args, **kwargs) platform.architecture = arch try: top = import_patched('dns') for pkg in ('dns', 'dns.rdtypes', 'dns.rdtypes.IN', 'dns.rdtypes.ANY'): mod = import_patched(pkg) for name in mod.__all__: setattr(mod, name, import_patched(pkg + '.' + name)) finally: platform.architecture = orig_arch return top
def _dns_import_patched(name): assert name.startswith('dns') import_patched(name) return dns