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

Skip to content

Commit e1a1674

Browse files
committed
Issue #17835: Fix test_io when the default OS pipe buffer size is larger than one million bytes.
1 parent 6ae4667 commit e1a1674

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

Lib/test/support.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,12 @@ def _is_ipv6_enabled():
573573
IPV6_ENABLED = _is_ipv6_enabled()
574574

575575

576-
# A constant likely larger than the underlying OS pipe buffer size.
577-
# Windows limit seems to be around 512B, and many Unix kernels have a 64K pipe
578-
# buffer size or 16*PAGE_SIZE: take a few megs to be sure. This
579-
PIPE_MAX_SIZE = 3 * 1000 * 1000
576+
# A constant likely larger than the underlying OS pipe buffer size, to
577+
# make writes blocking.
578+
# Windows limit seems to be around 512 B, and many Unix kernels have a
579+
# 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure.
580+
# (see issue #17835 for a discussion of this number).
581+
PIPE_MAX_SIZE = 4 *1024 * 1024 + 1
580582

581583

582584
# decorator for skipping tests on non-IEEE 754 platforms

Lib/test/test_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,7 +3061,7 @@ def _read():
30613061
# The buffered IO layer must check for pending signal
30623062
# handlers, which in this case will invoke alarm_interrupt().
30633063
self.assertRaises(ZeroDivisionError,
3064-
wio.write, item * (support.PIPE_MAX_SIZE // len(item)))
3064+
wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1))
30653065
t.join()
30663066
# We got one byte, get another one and check that it isn't a
30673067
# repeat of the first one.
@@ -3160,7 +3160,7 @@ def check_interrupted_write_retry(self, item, **fdopen_kwargs):
31603160
select = support.import_module("select")
31613161
# A quantity that exceeds the buffer size of an anonymous pipe's
31623162
# write end.
3163-
N = 1024 * 1024
3163+
N = support.PIPE_MAX_SIZE
31643164
r, w = os.pipe()
31653165
fdopen_kwargs["closefd"] = False
31663166
# We need a separate thread to read from the pipe and allow the

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ IDLE
132132
Tests
133133
-----
134134

135+
- Issue #17835: Fix test_io when the default OS pipe buffer size is larger
136+
than one million bytes.
137+
135138
- Issue #17065: Use process-unique key for winreg tests to avoid failures if
136139
test is run multiple times in parallel (eg: on a buildbot host).
137140

0 commit comments

Comments
 (0)