FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-137044: Make resource.RLIM_INFINITY always positive by serhiy-storchaka · Pull Request #137511 · python/cpython · GitHub

Repository navigation

gh-137044: Make resource.RLIM_INFINITY always positive - #137511

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:resource-RLIM_INFINITY
Aug 18, 2025
Merged

serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:resource-RLIM_INFINITY

Conversation

serhiy-storchaka commented Aug 7, 2025 •
edited
Loading

Copy link
Copy Markdown
Member

It is now a positive integer larger than any limited resource value. This simplifies comparison of the resource values. Previously, it could be negative, such as -1 or -3, depending on platform.

It is now a positive integer larger larger than any limited resource value.
This simplifies comparison of the resource values.
Previously, it could be negative, such as -1 or -3, depending on platform.

encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

OK, let's do this. It's the practical thing to do; if there are platforms that conform to POSIX in more interesting ways then we'll hopefullly notice in the 3.15 cycle.

Comment on lines +1 to +4
:data:`resource.RLIM_INFINITY` is now always a positive integer larger than
any limited resource value. This simplifies comparison of the resource
values. Previously, it could be negative, such as -1 or -3, depending on
platform.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think we test/guarantee that RLIM_INFINITY is bigger than limited values. AFAIK, POSIX would have no problem with RLIM_INFINITY being zero.
So, this should be:

Suggested change
:data:`resource.RLIM_INFINITY` is now always a positive integer larger than
any limited resource value. This simplifies comparison of the resource
values. Previously, it could be negative, such as -1 or -3, depending on
platform.
:data:`resource.RLIM_INFINITY` is now always a positive integer.
Previously, it could be negative, such as -1 or -3, depending on
platform.

or:

Suggested change
:data:`resource.RLIM_INFINITY` is now always a positive integer larger than
any limited resource value. This simplifies comparison of the resource
values. Previously, it could be negative, such as -1 or -3, depending on
platform.
:data:`resource.RLIM_INFINITY` is now always a positive integer.
On supported platforms, it is larger than any limited resource value,
which simplifies comparison of the resource values.
Previously, it could be negative, such as -1 or -3, depending on
platform.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

https://pubs.opengroup.org/onlinepubs/9799919799/functions/getrlimit.html

The value RLIM_INFINITY, defined in <sys/resource.h>, shall be considered to be larger than any other limit value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To be clear, I do not think this should have been merged without this change.

serhiy-storchaka merged commit 0324c72 into python:main Aug 18, 2025
serhiy-storchaka deleted the resource-RLIM_INFINITY branch August 18, 2025 16:29

zware commented Aug 19, 2025

Copy link
Copy Markdown
Member

This seems to have broken test_resource on 32-bit Linux; see for example https://buildbot.python.org/#/builders/1245/builds/6166

FAIL: test_fsize_not_too_big (test.test_resource.ResourceTest.test_fsize_not_too_big)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/test_resource.py", line 133, in test_fsize_not_too_big
    self.assertEqual(resource.getrlimit(resource.RLIMIT_FSIZE), expected(2**32))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Tuples differ: (18446744073709551615, 18446744073709551615) != (4294967296, 18446744073709551615)
First differing element 0:
18446744073709551615
4294967296
- (18446744073709551615, 18446744073709551615)
?  --    ^^^^^^^ --- --
+ (4294967296, 18446744073709551615)
?   ++ +  ^

Copy link
Copy Markdown
Member Author

Test fix: #137941.

Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…H-137511)

It is now a positive integer larger larger than any limited resource value.
This simplifies comparison of the resource values.
Previously, it could be negative, such as -1 or -3, depending on platform.

Deprecation warning is emitted if the old negative value is passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL