requests: requests.packages monkey patching of unbundled urllib3 does not work

In requests 2.5.2 requests.packages.__init__ added code to allow requests.packages.urllib3 to not exist, and it would fall back to using urllib3.

No doubt this works in some cases, as the people on #2375 were happy with it, but it doesnt work with pyopenssl, resulting in no SNI/etc.

requests.packages.__init__ only injects urllib3 as requests.packages.urllib3.

However all of the other modules within urlllib3 will have different copies in the namespace requests.packages.urllib3.

requests.packages.urllib3.contrib.pyopenssl then writes to a separate copy of requests.packages.urllib3.util and requests.packages.urllib3.connection, and these changes are never seen by urllib3.

I encountered this on debian stretch & sid’s python-requests 2.10.0-1 with python-urllib3 1.15.1 when running on Python 2.7.6 (Ubuntu Trusty), and haven’t retested yet on a later Python 2.7. @eriol #3286 fixes the problem for me.

I note that Fedora’s latest python-requests no longer unbundles urllib3.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 25 (20 by maintainers)

Most upvoted comments

Closing since Requests unvendored everything recently.