Skip to content

Commit

Permalink
Try to monkey patch httplib.HTTPResponse for PyPy 7.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Sep 28, 2020
1 parent 89d208f commit 27283e4
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions certvalidator/_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import unicode_literals, division, absolute_import, print_function

import sys
import platform

from asn1crypto import util

Expand All @@ -19,6 +20,19 @@

if sys.version_info < (3,):

# Workaround for https://foss.heptapod.net/pypy/pypy/-/issues/3313
if platform.python_implementation() == 'PyPy' and sys.pypy_version_info[0:3] == (7, 3, 2):
import httplib

def _drop(self):
pass

def _reuse(self):
pass

httplib.HTTPResponse._drop = _drop
httplib.HTTPResponse._reuse = _reuse

class Request(_Request, object):
"""
Compatibility shim to make urrlib2.Request handle unicode
Expand Down Expand Up @@ -53,21 +67,6 @@ def add_header(self, name, value):
value.encode('iso-8859-1')
)

def _reuse(self):
"""
Makes PyPy happy
"""

pass

def _drop(self):
"""
Makes PyPy happy
"""

pass


else:

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

super().__init__(url)
self.add_header('Host', self.host.split(":")[0])

def _reuse(self):
"""
Makes PyPy happy
"""

pass

def _drop(self):
"""
Makes PyPy happy
"""

pass

0 comments on commit 27283e4

Please sign in to comment.