repositori / bagas / requests

requests public ready

https://github.com/psf/requests commit 3c7baaa 48 berkas · 374 potongan 2026-11-21T15:17:50Z
48berkas
36berkas python
374potongan
python 36 markdown 5 yaml 2 text 2 toml 1 css 1 html 1
src/requests/packages.pypython 23 baris ditampilkan
1
import sys
2
3
from .compat import chardet
4
5
# This code exists for backwards compatibility reasons.
6
# I don't like it either. Just look the other way. :)
7
8
for package in ("urllib3", "idna"):
9
locals()[package] = __import__(package)
10
# This traversal is apparently necessary such that the identities are
11
# preserved (requests.packages.urllib3.* is urllib3.*)
12
for mod in list(sys.modules):
13
if mod == package or mod.startswith(f"{package}."):
14
sys.modules[f"requests.packages.{mod}"] = sys.modules[mod]
15
16
if chardet is not None:
17
target = chardet.__name__
18
for mod in list(sys.modules):
19
if mod == target or mod.startswith(f"{target}."):
20
imported_mod = sys.modules[mod]
21
sys.modules[f"requests.packages.{mod}"] = imported_mod
22
mod = mod.replace(target, "chardet")
23
sys.modules[f"requests.packages.{mod}"] = imported_mod