RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1313465 - urllib3 throwing exception when trying to str(err)
Summary: urllib3 throwing exception when trying to str(err)
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-urllib3
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Python Maintainers
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-01 16:14 UTC by Joel Diaz
Modified: 2017-01-17 16:44 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-17 16:44:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Joel Diaz 2016-03-01 16:14:56 UTC
Description of problem:
Trying to connect with urllib3's built-in pyopenssl to a dead URL results in an unexpected exception.


Version-Release number of selected component (if applicable):
python-urllib3-1.10.2-2.el7_1.noarch

How reproducible:
100%

Steps to Reproduce:
1. Try a simple script to connect to a non-running URL.

2. #!/usr/bin/python

import urllib3
from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()

http = urllib3.PoolManager()
http.request('GET', 'https://localhost/')

Actual results:
[CTR][root@9a3e220a0a39 site-packages]$ /root/python-test.py
Traceback (most recent call last):
  File "/root/python-test.py", line 8, in <module>
    http.request('GET', 'https://localhost/')
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 68, in request
    **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 81, in request_encode_url
    return self.urlopen(method, url, **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/poolmanager.py", line 161, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 545, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 345, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 315, in _raise_timeout
    if 'timed out' in str(err) or 'did not complete (read)' in str(err):  # Python 2.6
TypeError: __str__ returned non-string (type Error)


Expected results:
When using non-urllib3-pyopenssl (ie no inject_info_urllib3() call), you get: urllib3.exceptions.SSLError: [Errno 2] No such file or directory

Additional info:

Comment 2 Robert Kuska 2016-03-09 11:12:21 UTC
This was fixed in upstream by following patch:

https://github.com/Lukasa/urllib3/commit/6e7ae92b16ae365ce3b3bacb19dddab457657a9e

Comment 7 Charalampos Stratakis 2017-01-13 17:14:10 UTC
Can't reproduce with python-urllib3-1.10.2-2.el7_1.noarch as the error message I get is:

Traceback (most recent call last):
  File "./python-test.py", line 8, in <module>
    http.request('GET', 'https://localhost/')
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 68, in request
    **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 81, in request_encode_url
    return self.urlopen(method, url, **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/poolmanager.py", line 161, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python2.7/site-packages/urllib3/util/retry.py", line 271, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=443): Max retries exceeded with url: / (Caused by ProtocolError('Connection aborted.', error(111, 'Connection refused')))

Comment 8 Joel Diaz 2017-01-16 17:13:15 UTC
I'm seeing the expected (fixed) behavior:

[CTR][root@f4fb8924a8dc ~]$ rpm -qa | grep urllib
python-urllib3-1.10.2-2.el7_1.noarch
[CTR][root@f4fb8924a8dc ~]$ python
Python 2.7.5 (default, Aug  2 2016, 04:20:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib3
>>> from urllib3.contrib import pyopenssl                                                                                                                        
>>> pyopenssl.inject_into_urllib3()
>>> http = urllib3.PoolManager()
>>> http.request('GET', 'https://localhost/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 68, in request
    **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/request.py", line 81, in request_encode_url
    return self.urlopen(method, url, **urlopen_kw)
  File "/usr/lib/python2.7/site-packages/urllib3/poolmanager.py", line 161, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 574, in urlopen
    raise SSLError(e)
urllib3.exceptions.SSLError

Comment 9 Charalampos Stratakis 2017-01-17 10:11:24 UTC
So the issue is fixed actually? Can the bug be closed?

Comment 10 Joel Diaz 2017-01-17 15:04:38 UTC
(In reply to Charalampos Stratakis from comment #9)
> So the issue is fixed actually? Can the bug be closed?

Yep. The original problem is fixed.


Note You need to log in before you can comment on or make changes to this bug.