You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_resource fails when file size is limited #37883
I'm not sure of the benefit of this line. For machines
which have limited file sizes, it causes the test to fail.
Otherwise the test seems to work properly.
Martin, welcome back! Now I get to assign some bugs to you
to see if you have any input. :-)
loewis commented on Mar 30, 2003
loewismannequin
Mannequin
More actions
Logged In: YES
user_id=21627
The rationale of the line is explained in the comment: The
code tests whether the limit is a really large number, i.e.
whether represenation of large limits works.
Unfortunately, it doesn't (which is a separate issue): On
Linux, RLIM_INFINITY is reported as -1. This comes from
RLIM_INFINITY being the larges unsigned long long number,
i.e. 0xffffffffffffffffuLL. The resource module represents
this incorrectly.
I think there is no way to verify that Python computes the
real limit correctly (unless we invoke the shell's ulimit
for comparison). So you could weaken the test to verify that
the limit is non-negative (and, as a side effect, verify
that it doesn't raise an exception).
If you do so, you'll also have to fix the implementation, so
that the weakened-strengthened test passes on Linux.
nnorwitz commented on Mar 30, 2003
nnorwitzmannequin
MannequinAuthor
More actions
Logged In: YES
user_id=33168
Hmmm, sounds like a lot of work. How about something like this:
expected_max=resource.RLIM_INFINITYifexpected_max!=max:
# read the file resource limitfsize_ulimit=os.popen('ulimit -f').read()
try:
# convert the file size to bytes (from 512 byteblocks)
expected_max=int(fsize_ulimit.strip()) *512exceptValueError:
raiseTestSkipped, "unabletodetermineexpectedresourcevalue"
printexpected_max==max
This works, but I'm pretty sure this is not portable. On
Linux blocks are 1k. This only works when the block size is
512 bytes. Shall we close this bug as a test environment
problem and won't fix?
loewis commented on Mar 30, 2003
loewismannequin
Mannequin
More actions
Logged In: YES
user_id=21627
I'm really not that much concerned about fixing the test,
but more about fixing the code itself.
mdr0 commented on Mar 10, 2004
mdr0mannequin
Mannequin
More actions
Logged In: YES
user_id=994239
I'm running into this problem under AIX 4.3.3 and 5.1. Is
this going to cause a problem if I put python into
production, or is it "safe" to ignore it?
>ulimit -Hf 1000
>./python Lib/test/test_resource.py
....FEE.......
======================================================================
ERROR: test_fsize_negative (__main__.ResourceTest.test_fsize_negative)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/rdmurray/cpython/master/Lib/test/test_resource.py", line 168, in test_fsize_negative
resource.setrlimit(resource.RLIMIT_FSIZE, (value, max))
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: current limit exceeds maximum limit
[...]
It doesn't matter what you set to the limit to, if it is set to anything the tests fail. I suppose we could just skip them if the limit is set, but that feels like the wrong solution.
Activity
nnorwitz commentedon Jan 31, 2003
test_resource does:
print resource.RLIM_INFINITY == max
I'm not sure of the benefit of this line. For machines
which have limited file sizes, it causes the test to fail.
Otherwise the test seems to work properly.
nnorwitz commentedon Mar 3, 2003
Logged In: YES
user_id=33168
Martin, welcome back! Now I get to assign some bugs to you
to see if you have any input. :-)
loewis commentedon Mar 30, 2003
Logged In: YES
user_id=21627
The rationale of the line is explained in the comment: The
code tests whether the limit is a really large number, i.e.
whether represenation of large limits works.
Unfortunately, it doesn't (which is a separate issue): On
Linux, RLIM_INFINITY is reported as -1. This comes from
RLIM_INFINITY being the larges unsigned long long number,
i.e. 0xffffffffffffffffuLL. The resource module represents
this incorrectly.
I think there is no way to verify that Python computes the
real limit correctly (unless we invoke the shell's ulimit
for comparison). So you could weaken the test to verify that
the limit is non-negative (and, as a side effect, verify
that it doesn't raise an exception).
If you do so, you'll also have to fix the implementation, so
that the weakened-strengthened test passes on Linux.
nnorwitz commentedon Mar 30, 2003
Logged In: YES
user_id=33168
Hmmm, sounds like a lot of work. How about something like this:
This works, but I'm pretty sure this is not portable. On
Linux blocks are 1k. This only works when the block size is
512 bytes. Shall we close this bug as a test environment
problem and won't fix?
loewis commentedon Mar 30, 2003
Logged In: YES
user_id=21627
I'm really not that much concerned about fixing the test,
but more about fixing the code itself.
mdr0 commentedon Mar 10, 2004
Logged In: YES
user_id=994239
I'm running into this problem under AIX 4.3.3 and 5.1. Is
this going to cause a problem if I put python into
production, or is it "safe" to ignore it?
devdanzin commentedon Feb 13, 2009
Is this still a problem?
26 remaining items
ritesh006 commentedon Sep 1, 2025
Is this issue still relevant in 2025?
mir5903 commentedon Oct 23, 2025
Probably not because after that version that attribute have changed
bitdancer commentedon Oct 31, 2025
Looks like it is still relevant:
It doesn't matter what you set to the limit to, if it is set to anything the tests fail. I suppose we could just skip them if the limit is set, but that feels like the wrong solution.
bpo-678264/pythongh-37883: Fix test_resource failures with file size …
pythongh-37883: Fix test_resource.test_fsize_ismax for systems with l…
pythongh-37883: Safely skip test_resource file size tests when limits…
pythongh-37883: Safely skip test_resource file size tests when limits…
pythongh-37883: Safely skip test_resource file size tests when limits…
ajm19826 commentedon Mar 20, 2026
How is this issue created in 2003?
aiwonderland commentedon Mar 29, 2026
gh-37883: Safely skip test_resource file size tests when limits are s…
encukou commentedon Apr 8, 2026
Thank you for the fix, @Shrey-N!
pythongh-37883: Safely skip test_resource file size tests when limits…