adapters.py uses undefined name ProxyManager

Bug #1187429 reported by Colin Watson
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
requests (Debian)
Fix Released
Unknown
requests (Ubuntu)
Fix Released
High
Unassigned

Bug Description

With http_proxy set in my environment:

$ phablet-flash --list-revisions
Traceback (most recent call last):
  File "/usr/bin/phablet-flash", line 436, in <module>
    main(args)
  File "/usr/bin/phablet-flash", line 345, in main
    revisions = cdimage.get_available_revisions(settings.cdimage_uri_base)
  File "/usr/lib/python2.7/dist-packages/phabletutils/cdimage.py", line 47, in get_available_revisions
    releases = _get_releases(cdimage_uri)
  File "/usr/lib/python2.7/dist-packages/phabletutils/cdimage.py", line 37, in _get_releases
    releases = [{'release': i, 'uri': uri + i} for i in _get_elements(uri)]
  File "/usr/lib/python2.7/dist-packages/phabletutils/cdimage.py", line 25, in _get_elements
    request = requests.get(uri).content
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 354, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 460, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 191, in send
    conn = self.get_connection(request.url, proxies)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 140, in get_connection
    conn = ProxyManager(self.poolmanager.connection_from_url(proxy))
NameError: global name 'ProxyManager' is not defined

Revision history for this message
Colin Watson (cjwatson) wrote :

This is with phablet-tools 0.14daily13.05.31-0ubuntu1 (though I think that's irrelevant) and python-requests 1.2.0-2.

Revision history for this message
Yolanda Robla (yolanda.robla) wrote :

Thanks for reporting this.
I tested under your conditions and i got the same error. Marked as confirmed to be fixed soon.

Changed in requests (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Scott Moser (smoser) wrote :

just hit this also, a simple recreate:
 $ env -u http_proxy python -c 'import sys, requests; print(requests.get(sys.argv[1]).status_code)' http://ubuntu.com
 200
 $ env http_proxy=http://my.proxy:3128/ python -c 'import sys, requests; print(requests.get(sys.argv[1]).status_code)' http://ubuntu.com
Traceback (most recent call last):
  File "<string>", line 1, in <module>
....
NameError: global name 'ProxyManager' is not defined

both python and python3 fail.

Revision history for this message
Scott Moser (smoser) wrote :

Verified that this patch fixes issue:
--- /usr/share/pyshared/requests/adapters.py.dist 2013-06-12 22:17:59.472271230 -0400
+++ /usr/share/pyshared/requests/adapters.py 2013-06-12 22:18:38.720699670 -0400
@@ -11,7 +11,7 @@
 import socket

 from .models import Response
-from urllib3.poolmanager import PoolManager, proxy_from_url
+from urllib3.poolmanager import PoolManager, proxy_from_url, ProxyManager
 from urllib3.response import HTTPResponse
 from .compat import urlparse, basestring, urldefrag, unquote
 from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,

This was upstream fixed at https://github.com/kennethreitz/requests/commit/5152c98223d46c76cb7e88cb833b0087daf83d54
reported at https://github.com/kennethreitz/requests/issues/1017 .

Ie, it seems as simple as adding the import.

Changed in requests (Debian):
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package requests - 1.2.3-1

---------------
requests (1.2.3-1) unstable; urgency=low

  * New upstream release (Closes: #712915) (LP: #1187429)
    - Thanks to Scott Moser for the report
  * debian/compat
    - Bumped debhelper compatibility level to 9
  * debian/control
    - Bumped debhelper B-D to (>= 9)
    - Temporarily bumped X-Python-Version to >= 2.7 to prevent FTBFS
      due to lack of python-urllib3 for Python 2.6
  * debian/patches/02_use-system-chardet-and-urllib3.patches
    - Refreshed

 -- Daniele Tricoli <email address hidden> Fri, 21 Jun 2013 08:52:39 +0200

Changed in requests (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.