Skip to content

Commit

Permalink
Fix an error on pypy3
Browse files Browse the repository at this point in the history
Fix #72
  • Loading branch information
kovidgoyal committed Apr 25, 2022
1 parent 2fc6af9 commit 4198499
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mechanize/_urllib2_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ def md5_digest(data):
if platform.python_implementation() == 'PyPy':
def create_readline_wrapper(fh):
fh.recv = fh.read
if not hasattr(fh, '_drop'):
fh._drop = lambda: None
fh._reuse = lambda: None
return socket._fileobject(fh, close=True)
if is_py2:
if not hasattr(fh, '_drop'):
fh._drop = lambda: None
fh._reuse = lambda: None
ans = socket._fileobject(fh, close=True)
else:
fh.recv_into = fh.readinto
fh._decref_socketios = lambda: None
ans = BufferedReader(socket.SocketIO(fh, 'r'))
return ans
else:
def create_readline_wrapper(fh):
fh.recv = fh.read
Expand Down

0 comments on commit 4198499

Please sign in to comment.