Skip to content

Commit

Permalink
Patch asyncio.unix_events for bpo-38319 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Oct 27, 2020
1 parent b78d168 commit 2683137
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/3.8/asynctio_unix_events.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 1ff8c427da..0e8eb719ed 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -369,6 +369,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
fut.set_result(total_sent)
return

+ # On 32-bit architectures truncate to 1GiB to avoid OverflowError,
+ # see bpo-38319.
+ if sys.maxsize < 2 ** 32:
+ blocksize = min(blocksize, 2 ** 30)
+
try:
sent = os.sendfile(fd, fileno, offset, blocksize)
except (BlockingIOError, InterruptedError):
16 changes: 16 additions & 0 deletions python/3.9/asynctio_unix_events.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index f34a5b4b44..b1d0f1e61e 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -369,6 +369,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
fut.set_result(total_sent)
return

+ # On 32-bit architectures truncate to 1GiB to avoid OverflowError,
+ # see bpo-38319.
+ if sys.maxsize < 2 ** 32:
+ blocksize = min(blocksize, 2 ** 30)
+
try:
sent = os.sendfile(fd, fileno, offset, blocksize)
except (BlockingIOError, InterruptedError):

0 comments on commit 2683137

Please sign in to comment.