Skip to content

Commit c52da17

Browse files
authored
Fix urllib3 Recursion Regression (#410)
* Fix urllib3 recursion * Add regression testing for gevent * [Mega-Linter] Apply linters fixes * Add urllib3 to gevent tox env Co-authored-by: TimPansino <[email protected]>
1 parent 0cf1f12 commit c52da17

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

newrelic/packages/urllib3/contrib/_securetransport/bindings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949
from ctypes.util import find_library
5050

51-
from urllib3.packages.six import raise_from
51+
from ...packages.six import raise_from
5252

5353
if platform.system() != "Darwin":
5454
raise ImportError("Only macOS is supported")

newrelic/packages/urllib3/util/ssltransport.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import socket
33
import ssl
44

5-
from urllib3.exceptions import ProxySchemeUnsupported
6-
from urllib3.packages import six
5+
from ..exceptions import ProxySchemeUnsupported
6+
from ..packages import six
77

88
SSL_BLOCKSIZE = 16384
99

tests/adapter_gevent/test_patch_thread.py tests/adapter_gevent/test_patching.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import gevent.monkey
16-
1715

1816
def test_patch_thread():
17+
import gevent.monkey
18+
1919
gevent.monkey.patch_thread()
20+
21+
22+
def test_patch_ssl_recursion():
23+
import gevent.monkey
24+
25+
gevent.monkey.patch_all()
26+
27+
# Delay imports and test creation of contexts from both bundled and installed urllib3
28+
import urllib3.util.ssl_
29+
30+
import newrelic.packages.urllib3.util.ssl_
31+
32+
context1 = urllib3.util.ssl_.create_urllib3_context()
33+
context2 = newrelic.packages.urllib3.util.ssl_.create_urllib3_context()

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ deps =
157157
adapter_cheroot: cheroot
158158
adapter_gevent: WSGIProxy2
159159
adapter_gevent: gevent
160+
adapter_gevent: urllib3
160161
adapter_gunicorn-aiohttp1: aiohttp<2.0
161162
adapter_gunicorn-aiohttp3: aiohttp<4.0
162163
adapter_gunicorn-gunicorn19: gunicorn<20

0 commit comments

Comments
 (0)