From: Gabriel Date: Sun, 21 Oct 2012 14:49:50 +0000 (+0200) Subject: Remove path hacks that break chardet in Python 3. Closes #858. X-Git-Tag: v0.14.2~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c03553ed4ae856d1732ea7ce084549758dc5007f;p=services%2Fpython-requests.git 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. --- diff --git a/requests/_oauth.py b/requests/_oauth.py index 165e937..055154d 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)