File: 0001-Fix-an-error-on-pypy3.patch

package info (click to toggle)
python-mechanize 1%3A0.4.8%2Bpypi-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,612 kB
  • sloc: python: 16,644; makefile: 11
file content (34 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Mon, 25 Apr 2022 08:12:00 +0530
Subject: Fix an error on pypy3

Fix #72
---
 mechanize/_urllib2_fork.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mechanize/_urllib2_fork.py b/mechanize/_urllib2_fork.py
index df6bef2..f14f7fc 100644
--- a/mechanize/_urllib2_fork.py
+++ b/mechanize/_urllib2_fork.py
@@ -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