[llvm] [lit] Normalize RLIM_INFINITY to -1 in print_limits.py for Python 3.15+ (PR #190953)

Miro HronĨok via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 03:48:58 PDT 2026


https://github.com/hroncok updated https://github.com/llvm/llvm-project/pull/190953

>From 6ec16f181d041fe214282b51d59d24a6b357e961 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro at hroncok.cz>
Date: Wed, 8 Apr 2026 12:40:10 +0200
Subject: [PATCH] [lit] Normalize RLIM_INFINITY to -1 in print_limits.py for
 Python 3.15+

Python 3.15 changed resource.getrlimit() to return the platform's
maximum value (e.g., 18446744073709551615 on 64-bit systems) instead
of -1 for RLIM_INFINITY. This breaks lit tests that expect -1 for
unlimited resource limits.

This patch normalizes the return value to -1 when it equals
RLIM_INFINITY to maintain compatibility with existing tests across
all Python versions.

Fixes test failure: shtest-ulimit-nondarwin.py
Expected: RLIMIT_FSIZE=-1
Got: RLIMIT_FSIZE=18446744073709551615

Reference: https://github.com/python/cpython/commit/0324c726dea702282a0300225e989b19ae23b759
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=2448969

Analysis and testing assisted by AI.

Assisted-by: Claude Sonnet 4.5
---
 .../Inputs/shtest-ulimit/print_limits.py      | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py b/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
index c732c0429e661..a5f8ddab70b2e 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
@@ -1,6 +1,22 @@
 import resource
 
-print("RLIMIT_AS=" + str(resource.getrlimit(resource.RLIMIT_AS)[0]))
-print("RLIMIT_NOFILE=" + str(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
-print("RLIMIT_STACK=" + str(resource.getrlimit(resource.RLIMIT_STACK)[0]))
-print("RLIMIT_FSIZE=" + str(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
+
+def normalize_limit(limit_value):
+    """Normalize RLIM_INFINITY to -1 for consistency across Python versions.
+
+    Python 3.15+ returns the platform's max value (e.g., 2^64-1) instead of -1.
+    """
+    return -1 if limit_value == resource.RLIM_INFINITY else limit_value
+
+
+print("RLIMIT_AS=" + str(normalize_limit(resource.getrlimit(resource.RLIMIT_AS)[0])))
+print(
+    "RLIMIT_NOFILE="
+    + str(normalize_limit(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
+)
+print(
+    "RLIMIT_STACK=" + str(normalize_limit(resource.getrlimit(resource.RLIMIT_STACK)[0]))
+)
+print(
+    "RLIMIT_FSIZE=" + str(normalize_limit(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
+)



More information about the llvm-commits mailing list