From 3cae2262a0ddac67d547c69d209ebaf7174bf0b0 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Fri, 6 Mar 2026 12:50:26 +0500 Subject: [PATCH 01/15] gh-37883: Safely skip test_resource file size tests when limits are strict --- Lib/test/test_resource.py | 74 ++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 5fd076bee38e79..0e1738ef0ad04a 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -50,47 +50,49 @@ def test_fsize_ismax(self): "setting RLIMIT_FSIZE is not supported on VxWorks") @unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE') def test_fsize_enforced(self): - (cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE) - # Check to see what happens when the RLIMIT_FSIZE is small. Some - # versions of Python were terminated by an uncaught SIGXFSZ, but - # pythonrun.c has been fixed to ignore that exception. If so, the - # write() should return EFBIG when the limit is exceeded. + try: + (cur, max_lim) = resource.getrlimit(resource.RLIMIT_FSIZE) + except OSError as e: + self.skipTest(f"getrlimit(RLIMIT_FSIZE) failed: {e}") + + if max_lim != resource.RLIM_INFINITY and max_lim < 1025: + self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") - # At least one platform has an unlimited RLIMIT_FSIZE and attempts - # to change it raise ValueError instead. try: + resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) + except (ValueError, OSError, PermissionError) as e: + self.skipTest(f"cannot set RLIMIT_FSIZE to 1024: {e}") + + self.addCleanup(os_helper.unlink, os_helper.TESTFN) + self.addCleanup(resource.setrlimit, resource.RLIMIT_FSIZE, (cur, max_lim)) + + resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) + + f = open(os_helper.TESTFN, "wb") + try: + f.write(b"X" * 1024) try: - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max)) - limit_set = True - except ValueError: - limit_set = False - f = open(os_helper.TESTFN, "wb") - try: - f.write(b"X" * 1024) - try: - f.write(b"Y") + f.write(b"Y") + f.flush() + # On some systems (e.g., Ubuntu on hppa) the flush() + # doesn't always cause the exception, but the close() + # does eventually. Try flushing several times in + # an attempt to ensure the file is really synced and + # the exception raised. + for i in range(5): + time.sleep(.1) f.flush() - # On some systems (e.g., Ubuntu on hppa) the flush() - # doesn't always cause the exception, but the close() - # does eventually. Try flushing several times in - # an attempt to ensure the file is really synced and - # the exception raised. - for i in range(5): - time.sleep(.1) - f.flush() - except OSError: - if not limit_set: - raise - if limit_set: - # Close will attempt to flush the byte we wrote - # Restore limit first to avoid getting a spurious error - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) - finally: - f.close() + except OSError: + pass + else: + self.fail("f.write() did not raise OSError when exceeding RLIMIT_FSIZE") + + # Close will attempt to flush the byte we wrote + # Restore limit first to avoid getting a spurious error + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) finally: - if limit_set: - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max)) - os_helper.unlink(os_helper.TESTFN) + f.close() @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") From f217fb1a9dcbeec2b51e5187b9207d6fb94fd2a7 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:43:51 +0000 Subject: [PATCH 02/15] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst diff --git a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst new file mode 100644 index 00000000000000..f301cba7e9cb98 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst @@ -0,0 +1 @@ +Fix :meth:`test_resource.test_fsize_enforced` to gracefully skip when the system hard limit or privileges prevent setting file size limits. From ef28dbcb738a0a0df4ce3ad487a9385802f59cd8 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Fri, 6 Mar 2026 17:00:55 +0500 Subject: [PATCH 03/15] Update News Entry --- .../next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst index f301cba7e9cb98..a047b69646c4ab 100644 --- a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst +++ b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst @@ -1 +1 @@ -Fix :meth:`test_resource.test_fsize_enforced` to gracefully skip when the system hard limit or privileges prevent setting file size limits. +Fix ``test_resource.test_fsize_enforced`` to gracefully skip when the system hard limit or privileges prevent setting file size limits. From f74f58e493a13375bdd4d836704dadba0c02aa5e Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 8 Mar 2026 18:49:16 +0500 Subject: [PATCH 04/15] Update 2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst --- .../next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst index a047b69646c4ab..b013828c8fe579 100644 --- a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst +++ b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst @@ -1 +1 @@ -Fix ``test_resource.test_fsize_enforced`` to gracefully skip when the system hard limit or privileges prevent setting file size limits. +Fix ``test_resource.test_fsize_enforced`` to gracefully skip when the system hard limit or privileges prevent setting file size limits. Patch by Shrey Naithani From d21ceb8a8185410de5b111fbaff026455e6ed129 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 10 Mar 2026 20:22:49 +0530 Subject: [PATCH 05/15] Refactor test_resource.py on the advice --- Lib/test/test_resource.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 0e1738ef0ad04a..d842846f991b9f 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -68,31 +68,25 @@ def test_fsize_enforced(self): self.addCleanup(resource.setrlimit, resource.RLIMIT_FSIZE, (cur, max_lim)) resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) - - f = open(os_helper.TESTFN, "wb") + try: - f.write(b"X" * 1024) - try: - f.write(b"Y") - f.flush() - # On some systems (e.g., Ubuntu on hppa) the flush() - # doesn't always cause the exception, but the close() - # does eventually. Try flushing several times in - # an attempt to ensure the file is really synced and - # the exception raised. - for i in range(5): - time.sleep(.1) + with open(os_helper.TESTFN, "wb") as f: + f.write(b"X" * 1024) + # This should raise OSError because it exceeds the 1024 byte limit + with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): + f.write(b"Y") f.flush() - except OSError: - pass - else: - self.fail("f.write() did not raise OSError when exceeding RLIMIT_FSIZE") - - # Close will attempt to flush the byte we wrote - # Restore limit first to avoid getting a spurious error - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) + # On some systems (e.g., Ubuntu on hppa) the flush() + # doesn't always cause the exception, but the close() + # does eventually. Try flushing several times in + # an attempt to ensure the file is really synced and + # the exception raised. + for i in range(5): + time.sleep(.1) + f.flush() finally: - f.close() + # Restore limit after the file is closed by the 'with' block + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") From 65b0b8800b28f64d25c798c60b94d64f383863c6 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 10 Mar 2026 20:24:32 +0530 Subject: [PATCH 06/15] fix lint error Remove unnecessary blank line --- Lib/test/test_resource.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index d842846f991b9f..428eb3dac3fb3b 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -66,9 +66,7 @@ def test_fsize_enforced(self): self.addCleanup(os_helper.unlink, os_helper.TESTFN) self.addCleanup(resource.setrlimit, resource.RLIMIT_FSIZE, (cur, max_lim)) - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) - try: with open(os_helper.TESTFN, "wb") as f: f.write(b"X" * 1024) From 1600c310ea0fc8372a7cde1a47a9b75f4c232892 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 10 Mar 2026 21:30:58 +0530 Subject: [PATCH 07/15] Update test_resource.py --- Lib/test/test_resource.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 428eb3dac3fb3b..d66a6a9919afca 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -58,17 +58,10 @@ def test_fsize_enforced(self): if max_lim != resource.RLIM_INFINITY and max_lim < 1025: self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") - try: - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) - except (ValueError, OSError, PermissionError) as e: - self.skipTest(f"cannot set RLIMIT_FSIZE to 1024: {e}") - - self.addCleanup(os_helper.unlink, os_helper.TESTFN) - self.addCleanup(resource.setrlimit, resource.RLIMIT_FSIZE, (cur, max_lim)) - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) try: with open(os_helper.TESTFN, "wb") as f: + resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) + f.write(b"X" * 1024) # This should raise OSError because it exceeds the 1024 byte limit with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): @@ -83,9 +76,8 @@ def test_fsize_enforced(self): time.sleep(.1) f.flush() finally: - # Restore limit after the file is closed by the 'with' block resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) - + @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") @unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE') From 7fb6b7214b279dd5c54033c4a4b486df9fe755e4 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Tue, 10 Mar 2026 21:32:54 +0530 Subject: [PATCH 08/15] Fix formatting in test_resource.py --- Lib/test/test_resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index d66a6a9919afca..47df49bb45bb3d 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -77,7 +77,7 @@ def test_fsize_enforced(self): f.flush() finally: resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) - + @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") @unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE') From 29255c2c8cc3fd5f4ef4f380f48febfb3a26ce7f Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Wed, 11 Mar 2026 22:22:28 +0530 Subject: [PATCH 09/15] Update test_resource.py --- Lib/test/test_resource.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 47df49bb45bb3d..aa5b91ed5edeaf 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -57,24 +57,26 @@ def test_fsize_enforced(self): if max_lim != resource.RLIM_INFINITY and max_lim < 1025: self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") - try: - with open(os_helper.TESTFN, "wb") as f: - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) - - f.write(b"X" * 1024) - # This should raise OSError because it exceeds the 1024 byte limit - with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): - f.write(b"Y") - f.flush() - # On some systems (e.g., Ubuntu on hppa) the flush() - # doesn't always cause the exception, but the close() - # does eventually. Try flushing several times in - # an attempt to ensure the file is really synced and - # the exception raised. - for i in range(5): - time.sleep(.1) + try: + with open(os_helper.TESTFN, "wb") as f: + resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) + f.write(b"X" * 1024) + with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): + f.write(b"Y") f.flush() + # On some systems (e.g., Ubuntu on hppa) the flush() + # doesn't always cause the exception, but the close() + # does eventually. Try flushing several times in + # an attempt to ensure the file is really synced and + # the exception raised. + for i in range(5): + time.sleep(.1) + f.flush() + except OSError as e: + if e.errno == errno.EFBIG: + self.skipTest(f"ASAN/OS raised EFBIG prematurely on open/setup: {e}") + raise finally: resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) From 3dc4653804b6ff098cb98e2492dcffb1d075b413 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 20:39:45 +0500 Subject: [PATCH 10/15] Update test_resource.py --- Lib/test/test_resource.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index aa5b91ed5edeaf..dbec97bbbfb41d 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -57,29 +57,16 @@ def test_fsize_enforced(self): if max_lim != resource.RLIM_INFINITY and max_lim < 1025: self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") - try: + with open(os_helper.TESTFN, "wb") as f: try: - with open(os_helper.TESTFN, "wb") as f: - resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) - f.write(b"X" * 1024) - with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): - f.write(b"Y") - f.flush() - # On some systems (e.g., Ubuntu on hppa) the flush() - # doesn't always cause the exception, but the close() - # does eventually. Try flushing several times in - # an attempt to ensure the file is really synced and - # the exception raised. - for i in range(5): - time.sleep(.1) - f.flush() - except OSError as e: - if e.errno == errno.EFBIG: - self.skipTest(f"ASAN/OS raised EFBIG prematurely on open/setup: {e}") - raise - finally: - resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) - + resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) + f.write(b"X" * 1024) + with self.assertRaises(OSError, msg="f.write() did not raise OSError when exceeding RLIMIT_FSIZE"): + f.write(b"Y") + finally: + # Close will attempt to flush the byte we wrote + # Restore limit first to avoid getting a spurious error + resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max_lim)) @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") @unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE') From de3c7926a43287812e5bb25932466d2aad758c2d Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 20:41:26 +0500 Subject: [PATCH 11/15] Fix indentation in test_resource.py --- Lib/test/test_resource.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index dbec97bbbfb41d..0903514519427e 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -54,7 +54,6 @@ def test_fsize_enforced(self): (cur, max_lim) = resource.getrlimit(resource.RLIMIT_FSIZE) except OSError as e: self.skipTest(f"getrlimit(RLIMIT_FSIZE) failed: {e}") - if max_lim != resource.RLIM_INFINITY and max_lim < 1025: self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") with open(os_helper.TESTFN, "wb") as f: From 61822ddffae0d98287543c02a626b70dead6f98f Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 20:42:58 +0500 Subject: [PATCH 12/15] Remove unused 'time' import from test_resource.py Removed unused import of the 'time' module. --- Lib/test/test_resource.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 0903514519427e..76035ca00ea0e6 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -4,7 +4,6 @@ from test import support from test.support import import_helper from test.support import os_helper -import time resource = import_helper.import_module('resource') From 3b021808ae8660898be9a1ea95dc595a0a0b35a9 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 20:44:15 +0500 Subject: [PATCH 13/15] Delete Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst --- .../next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst diff --git a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst b/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst deleted file mode 100644 index b013828c8fe579..00000000000000 --- a/Misc/NEWS.d/next/Tests/2026-03-06-09-43-49.gh-issue-37883.I-3oZq.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``test_resource.test_fsize_enforced`` to gracefully skip when the system hard limit or privileges prevent setting file size limits. Patch by Shrey Naithani From befd67afbe2d92aa5e283265683d64ae6a4a82b4 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 20:44:59 +0500 Subject: [PATCH 14/15] Update test_resource.py --- Lib/test/test_resource.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 76035ca00ea0e6..862cbdb69aeaf1 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -68,6 +68,7 @@ def test_fsize_enforced(self): @unittest.skipIf(sys.platform == "vxworks", "setting RLIMIT_FSIZE is not supported on VxWorks") @unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE') + def test_fsize_too_big(self): # Be sure that setrlimit is checking for really large values too_big = 10**50 From 16acaa40307affa60ae4d5e2063f5de90388a2a2 Mon Sep 17 00:00:00 2001 From: Shrey Naithani Date: Sun, 15 Mar 2026 21:30:03 +0500 Subject: [PATCH 15/15] Update test_resource.py --- Lib/test/test_resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 862cbdb69aeaf1..f658220d8b6a8a 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -55,7 +55,7 @@ def test_fsize_enforced(self): self.skipTest(f"getrlimit(RLIMIT_FSIZE) failed: {e}") if max_lim != resource.RLIM_INFINITY and max_lim < 1025: self.skipTest(f"system RLIMIT_FSIZE hard limit ({max_lim}) is too small for this test") - with open(os_helper.TESTFN, "wb") as f: + with open(os_helper.TESTFN, "wb", buffering=0) as f: try: resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max_lim)) f.write(b"X" * 1024)