From 1b5bfe681b4c0a987e97ae78b2034db7b7ce3d01 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Sun, 5 Apr 2015 20:48:35 -0500 Subject: [PATCH] Place VendorAlias first in meta_path 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 --- requests/packages/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/packages/__init__.py b/requests/packages/__init__.py index 4dcf870f..b73b4d1b 100644 --- a/requests/packages/__init__.py +++ b/requests/packages/__init__.py @@ -104,4 +104,4 @@ class VendorAlias(object): return module -sys.meta_path.append(VendorAlias(["urllib3", "chardet"])) +sys.meta_path.insert(0, VendorAlias(["urllib3", "chardet"]))