I found that packages.py is assigning sys.modules['requests.package.chardet'] over and over with different modules, is this intentional or a bug?
I looked at the code and this target variable confuses me, it is assigned again in loop and placed with itself(so completely?), looks like a name confliction to me. Code is referenced from installed version 2.28.1.
target = chardet.__name__
for mod in list(sys.modules):
if mod == target or mod.startswith(f"{target}."):
target = target.replace(target, "chardet")
sys.modules[f"requests.packages.{target}"] = sys.modules[mod]
Expected Result
every chardet.* package maps to requests.packages.chardet.* respectively
Actual Result
only requests.package.chardet is assigned at last.
Reproduction Steps
import requests
import sys
print([m for m in sys.modules if name.startswith('requests.packages.chardet')])
I found that packages.py is assigning sys.modules['requests.package.chardet'] over and over with different modules, is this intentional or a bug?
I looked at the code and this
targetvariable confuses me, it is assigned again in loop and placed with itself(so completely?), looks like a name confliction to me. Code is referenced from installed version 2.28.1.Expected Result
every chardet.* package maps to requests.packages.chardet.* respectively
Actual Result
only requests.package.chardet is assigned at last.
Reproduction Steps
import requests
import sys
print([m for m in sys.modules if name.startswith('requests.packages.chardet')])