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

Skip to content

Commit 8c78c6d

Browse files
authored
Merge branch 'main' into gh-106976-other-tasks
2 parents 2b7804f + 9eeb4b4 commit 8c78c6d

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Lib/asyncio/unix_events.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno,
394394
fut.set_result(total_sent)
395395
return
396396

397+
# On 32-bit architectures truncate to 1GiB to avoid OverflowError
398+
blocksize = min(blocksize, sys.maxsize//2 + 1)
399+
397400
try:
398401
sent = os.sendfile(fd, fileno, offset, blocksize)
399402
except (BlockingIOError, InterruptedError):

Lib/test/test_capi/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,7 @@ def get_first_executor(func):
24362436
co_code = code.co_code
24372437
JUMP_BACKWARD = opcode.opmap["JUMP_BACKWARD"]
24382438
for i in range(0, len(co_code), 2):
2439-
if co_code[i] == JUMP_BACKWARD or 1:
2439+
if co_code[i] == JUMP_BACKWARD:
24402440
try:
24412441
return _testinternalcapi.get_executor(code, i)
24422442
except ValueError:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix overflow on 32-bit systems with :mod:`asyncio` :func:`os.sendfile` implemention.

0 commit comments

Comments
 (0)