Skip to content

Commit 27283e4

Browse files
committed
Try to monkey patch httplib.HTTPResponse for PyPy 7.3.2
1 parent 89d208f commit 27283e4

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

certvalidator/_urllib.py

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import unicode_literals, division, absolute_import, print_function
66

77
import sys
8+
import platform
89

910
from asn1crypto import util
1011

@@ -19,6 +20,19 @@
1920

2021
if sys.version_info < (3,):
2122

23+
# Workaround for https://foss.heptapod.net/pypy/pypy/-/issues/3313
24+
if platform.python_implementation() == 'PyPy' and sys.pypy_version_info[0:3] == (7, 3, 2):
25+
import httplib
26+
27+
def _drop(self):
28+
pass
29+
30+
def _reuse(self):
31+
pass
32+
33+
httplib.HTTPResponse._drop = _drop
34+
httplib.HTTPResponse._reuse = _reuse
35+
2236
class Request(_Request, object):
2337
"""
2438
Compatibility shim to make urrlib2.Request handle unicode
@@ -53,21 +67,6 @@ def add_header(self, name, value):
5367
value.encode('iso-8859-1')
5468
)
5569

56-
def _reuse(self):
57-
"""
58-
Makes PyPy happy
59-
"""
60-
61-
pass
62-
63-
def _drop(self):
64-
"""
65-
Makes PyPy happy
66-
"""
67-
68-
pass
69-
70-
7170
else:
7271

7372
class Request(_Request):
@@ -85,17 +84,3 @@ def __init__(self, url):
8584

8685
super().__init__(url)
8786
self.add_header('Host', self.host.split(":")[0])
88-
89-
def _reuse(self):
90-
"""
91-
Makes PyPy happy
92-
"""
93-
94-
pass
95-
96-
def _drop(self):
97-
"""
98-
Makes PyPy happy
99-
"""
100-
101-
pass

0 commit comments

Comments
 (0)