Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bf7138

Browse files
committed
Make test_socket work.
Don't exclude test_socket from the tests to run.
1 parent 7cad4f3 commit 2bf7138

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

Lib/io.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,23 @@ def isatty(self) -> bool:
300300

301301
def readline(self, limit: int = -1) -> bytes:
302302
"""For backwards compatibility, a (slowish) readline()."""
303+
if hasattr(self, "peek"):
304+
def nreadahead():
305+
readahead = self.peek(1, unsafe=True)
306+
if not readahead:
307+
return 1
308+
n = (readahead.find(b"\n") + 1) or len(readahead)
309+
if limit >= 0:
310+
n = min(n, limit)
311+
return n
312+
else:
313+
def nreadahead():
314+
return 1
303315
if limit is None:
304316
limit = -1
305317
res = bytes()
306318
while limit < 0 or len(res) < limit:
307-
readahead = self.peek(1, unsafe=True)
308-
if not readahead:
309-
break
310-
n = (readahead.find(b"\n") + 1) or len(readahead)
311-
if limit >= 0:
312-
n = min(n, limit)
313-
b = self.read(n)
319+
b = self.read(nreadahead())
314320
if not b:
315321
break
316322
res += b

runtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mkdir -p OUT
2727
# Compute the list of tests to run.
2828
case $# in
2929
0)
30-
TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | grep -v test_socket)`
30+
TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
3131
;;
3232
*)
3333
TESTS="$@"

0 commit comments

Comments
 (0)