Remove path hacks that break chardet in Python 3. Closes #858.
authorGabriel <g2p.code@gmail.com>
Sun, 21 Oct 2012 14:49:50 +0000 (16:49 +0200)
committerGabriel <g2p.code@gmail.com>
Sun, 21 Oct 2012 15:07:12 +0000 (17:07 +0200)
This replaces the sys.path hack with a slightly less objectionable
sys.modules hack.

Both have the effect of making the vendored lib's absolue imports work
as expected when oauthlib isn't installed. The sys.modules hack doesn't
insert the rest of the vendored crap in a global path, however.

requests/_oauth.py

index 165e937..055154d 100644 (file)
@@ -16,9 +16,8 @@ try:
     from oauthlib.common import extract_params
     from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER)
 except ImportError:
-    directory = os.path.dirname(__file__)
-    path = os.path.join(directory, 'packages')
-    sys.path.insert(0, path)
+    from .packages import oauthlib
+    sys.modules['oauthlib'] = oauthlib
     from oauthlib.oauth1 import rfc5849
     from oauthlib.common import extract_params
     from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER)