annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/requests/packages.py @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 import sys
jpayne@69 2
jpayne@69 3 from .compat import chardet
jpayne@69 4
jpayne@69 5 # This code exists for backwards compatibility reasons.
jpayne@69 6 # I don't like it either. Just look the other way. :)
jpayne@69 7
jpayne@69 8 for package in ("urllib3", "idna"):
jpayne@69 9 locals()[package] = __import__(package)
jpayne@69 10 # This traversal is apparently necessary such that the identities are
jpayne@69 11 # preserved (requests.packages.urllib3.* is urllib3.*)
jpayne@69 12 for mod in list(sys.modules):
jpayne@69 13 if mod == package or mod.startswith(f"{package}."):
jpayne@69 14 sys.modules[f"requests.packages.{mod}"] = sys.modules[mod]
jpayne@69 15
jpayne@69 16 if chardet is not None:
jpayne@69 17 target = chardet.__name__
jpayne@69 18 for mod in list(sys.modules):
jpayne@69 19 if mod == target or mod.startswith(f"{target}."):
jpayne@69 20 imported_mod = sys.modules[mod]
jpayne@69 21 sys.modules[f"requests.packages.{mod}"] = imported_mod
jpayne@69 22 mod = mod.replace(target, "chardet")
jpayne@69 23 sys.modules[f"requests.packages.{mod}"] = imported_mod