Closed
Description
Hello,
I understand that urllib3 doesn't support python2 anymore, so maybe this is something you are not willing to fix, but I though about reporting it since we are still in the process of migrating to python3.
This is how mixpanel creates the connection pool:
cert_reqs = 'CERT_REQUIRED' if verify_cert else 'CERT_NONE'
self._http = urllib3.PoolManager(
retries=retry_config,
timeout=urllib3.Timeout(request_timeout),
cert_reqs=cert_reqs,
)
but since we are importing for future:
from __future__ import absolute_import, unicode_literals
both in python2 and python3 cert_reqs
is a unicode. But please also notice that for python2 (unlike python3) unicode is not an instance of str, so in urllib3:
def resolve_cert_reqs(candidate):
"""
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_REQUIRED`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbreviation.
(So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
If it's neither `None` nor a string we assume it is already the numeric
constant which can directly be passed to wrap_socket.
"""
if candidate is None:
return CERT_REQUIRED
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, "CERT_" + candidate)
return res
return candidate
candidate will not be correctly resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels