From c03553ed4ae856d1732ea7ce084549758dc5007f Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 21 Oct 2012 16:49:50 +0200 Subject: [PATCH] Remove path hacks that break chardet in Python 3. Closes #858. 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/requests/_oauth.py b/requests/_oauth.py index 165e937e..055154d0 100644 --- a/requests/_oauth.py +++ b/requests/_oauth.py @@ -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)