GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-137044: Make resource.RLIM_INFINITY always positive by serhiy-storchaka · Pull Request #137511 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

  • Issue: resource library (getrlimit, setrlimit) interprets resource limits as signed integers instead of unsigned #137044

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-137044: Make resource.RLIM_INFINITY always positive
8b78682
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.
@serhiy-storchaka
serhiy-storchaka requested a review from encukou August 7, 2025 09:35
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 7, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 7, 2025
resource library (getrlimit, setrlimit) interprets resource limits as signed integers instead of unsigned #137044
Closed
serhiy-storchaka added 2 commits August 8, 2025 15:04
@serhiy-storchaka
Merge branch 'main' into resource-RLIM_INFINITY
55ca981
@serhiy-storchaka
Continue support of negative values.
03b8f07
@serhiy-storchaka
serhiy-storchaka requested a review from AA-Turner as a code owner August 8, 2025 12:51
encukou
encukou approved these changes Aug 18, 2025
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2025-08-07-12-32-23.gh-issue-137044.abNoIy.rst
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.

@encukou encukou Aug 18, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Aug 18, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Aug 19, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Aug 18, 2025
@serhiy-storchaka
serhiy-storchaka merged commit 0324c72 into python:main Aug 18, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 18, 2025
@serhiy-storchaka
serhiy-storchaka deleted the resource-RLIM_INFINITY branch August 18, 2025 16:29
@zware

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)
?   ++ +  ^
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

encukou added a commit to encukou/cpython that referenced this pull request Aug 19, 2025
@encukou
Revert "pythongh-137044: Make resource.RLIM_INFINITY always positive (p…
6b8dc49
…ythonGH-137511)"

This reverts commit 0324c72.
@encukou encukou mentioned this pull request Aug 19, 2025
gh-137044: Revert "gh-137044: Make resource.RLIM_INFINITY always positive (GH-137511)" #137938
Closed
@serhiy-storchaka

serhiy-storchaka commented Aug 19, 2025

Copy link
Copy Markdown
Member Author

Test fix: #137941.

zware reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@serhiy-storchaka @Agent-Hellboy
pythongh-137044: Make resource.RLIM_INFINITY always positive (pythonG…
494e0b9
…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.
@niksauer niksauer mentioned this pull request Oct 12, 2026
semgrep-core crashes on Python 3.15 (Linux): stack limit derived from RLIM_INFINITY / 3 semgrep/semgrep#11979
Open
1 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @zware @encukou
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.