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