Skip to content
Myr

Place VendorAlias first in meta_path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When other libraries or tools add items to the meta_path, we need to preempt some of their import hooks to be sure modules can be properly found. This also prevents problems importing built-in modules on Python 2 where it will first attempt to import something like: requests.packages.chardet.sys By placing our VendorAlias first, the above will fail and then it will fall back to trying to import sys directly instead. Closes #2465

authored by Ian Cordasco · committed by Ian Cordasco · parent 460caf7 · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:requests/packages/__init__.py+1 added-1 removed
102 unmodified lines
103 # Finally, return the loaded module104 return module105106107sys.meta_path.append(VendorAlias(["urllib3", "chardet"]))107sys.meta_path.insert(0, VendorAlias(["urllib3", "chardet"]))