Package: python-requests
Version: 2.12.4-1
Severity: important
Tags: patch

Hello,

thank you for maintaining python-requests.

It seems that patch use-pip-unbundling.patch doen not work as expected:

    >>> import sys, urllib3
    >>> from urllib3.exceptions import HTTPError
    >>> urllib3.exceptions.HTTPError is HTTPError
    True
    >>> sys.modules["urllib3.exceptions"] is urllib3.exceptions
    True
    >>> import requests
    >>> urllib3.exceptions.HTTPError is HTTPError
    False
    >>> sys.modules["urllib3.exceptions"] is urllib3.exceptions
    False

This causes (otherwise correct) Python programs to fail by simply
importing the 'requests' module. The solution proposed by upstream[1]
doesn't work either.

[1] 
https://github.com/kennethreitz/requests/blob/master/requests/packages/__init__.py

Attached is a patch that works for me and seems to fix the above bug.
It would be great if this could be fixed for stretch.

Best,

-- 
Ilias
diff -pru old/debian/patches/use-pip-unbundling.patch new/debian/patches/use-pip-unbundling.patch
--- old/debian/patches/use-pip-unbundling.patch	2017-04-04 13:31:19.965450626 +0300
+++ new/debian/patches/use-pip-unbundling.patch	2017-04-04 13:35:17.882779284 +0300
@@ -10,11 +10,11 @@ Patch-Name: use-pip-unbundling.patch
  requests/packages/__init__.py | 66 +++++++++++++++++++++++++++++++++----------
  1 file changed, 51 insertions(+), 15 deletions(-)
 
-diff --git a/requests/packages/__init__.py b/requests/packages/__init__.py
-index 4077265..b1206b2 100644
+Index: b/requests/packages/__init__.py
+===================================================================
 --- a/requests/packages/__init__.py
 +++ b/requests/packages/__init__.py
-@@ -23,20 +23,56 @@ request.
+@@ -23,20 +23,54 @@ request.
  from __future__ import absolute_import
  import sys
  
@@ -34,24 +34,21 @@ index 4077265..b1206b2 100644
 -    import chardet
 -    sys.modules['%s.chardet' % __name__] = chardet
 +    try:
-+        __import__(vendored_name, globals(), locals(), level=0)
++        __import__(modulename, globals(), locals(), level=0)
 +    except ImportError:
-+        try:
-+            __import__(modulename, globals(), locals(), level=0)
-+        except ImportError:
-+            # We can just silently allow import failures to pass here. If we
-+            # got to this point it means that ``import requests.packages.whatever``
-+            # failed and so did ``import whatever``. Since we're importing this
-+            # upfront in an attempt to alias imports, not erroring here will
-+            # just mean we get a regular import error whenever requests
-+            # *actually* tries to import one of these modules to use it, which
-+            # actually gives us a better error message than we would have
-+            # otherwise gotten.
-+            pass
-+        else:
-+            sys.modules[vendored_name] = sys.modules[modulename]
-+            base, head = vendored_name.rsplit(".", 1)
-+            setattr(sys.modules[base], head, sys.modules[modulename])
++        # We can just silently allow import failures to pass here. If we
++        # got to this point it means that ``import requests.packages.whatever``
++        # failed and so did ``import whatever``. Since we're importing this
++        # upfront in an attempt to alias imports, not erroring here will
++        # just mean we get a regular import error whenever requests
++        # *actually* tries to import one of these modules to use it, which
++        # actually gives us a better error message than we would have
++        # otherwise gotten.
++        pass
++    else:
++        sys.modules[vendored_name] = sys.modules[modulename]
++        base, head = vendored_name.rsplit(".", 1)
++        setattr(sys.modules[base], head, sys.modules[modulename])
  
 -try:
 -    from . import idna
@@ -67,6 +64,7 @@ index 4077265..b1206b2 100644
 +vendored('urllib3.contrib')
 +vendored('urllib3.contrib.ntlmpool')
 +vendored('urllib3.contrib.pyopenssl')
++vendored('urllib3.contrib.socks')
 +vendored('urllib3.exceptions')
 +vendored('urllib3.fields')
 +vendored('urllib3.filepost')
_______________________________________________
Python-modules-team mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

Reply via email to