Skip to content

test_resource fails when file size is limited #37883

Closed

Description

@nnorwitz
mannequin
BPO 678264
Nosy @loewis, @giampaolo, @devdanzin, @bitdancer, @wiggin15

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2003-01-31.18:06:24.000>
labels = ['type-bug', 'tests', '3.9', '3.10', '3.11']
title = 'test_resource fails when file size is limited'
updated_at = <Date 2021-12-17.00:35:56.774>
user = 'https://bugs.python.org/nnorwitz'

bugs.python.org fields:

activity = <Date 2021-12-17.00:35:56.774>
actor = 'ajaksu2'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Tests']
creation = <Date 2003-01-31.18:06:24.000>
creator = 'nnorwitz'
dependencies = []
files = []
hgrepos = []
issue_num = 678264
keywords = []
message_count = 18.0
messages = ['14342', '14343', '14344', '14345', '14346', '14347', '81850', '114216', '116449', '116479', '116520', '117049', '117051', '117122', '117130', '221696', '227778', '251772']
nosy_count = 8.0
nosy_names = ['loewis', 'nnorwitz', 'mdr0', 'sable', 'giampaolo.rodola', 'ajaksu2', 'r.david.murray', 'wiggin15']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue678264'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

Activity

  1. nnorwitz commented on Jan 31, 2003

    nnorwitzmannequin
    MannequinAuthor

    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.

  2. self-assigned this
    on Jan 31, 2003
  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 31, 2003
  4. self-assigned this
    on Jan 31, 2003
  5. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 31, 2003
  6. nnorwitz commented on Mar 3, 2003

    nnorwitzmannequin
    MannequinAuthor

    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. :-)

  7. loewis commented on Mar 30, 2003

    loewismannequin
    Mannequin

    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.

  8. nnorwitz commented on Mar 30, 2003

    nnorwitzmannequin
    MannequinAuthor

    Logged In: YES
    user_id=33168

    Hmmm, sounds like a lot of work. How about something like this:

        expected_max = resource.RLIM_INFINITY
        if expected_max != max:
            # read the file resource limit
            fsize_ulimit = os.popen('ulimit -f').read()
            try:
                # convert the file size to bytes (from 512 byte
    blocks)
                expected_max = int(fsize_ulimit.strip()) * 512
            except ValueError:
                raise TestSkipped, "unable to determine expected
    resource value"
        print expected_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?

  9. loewis commented on Mar 30, 2003

    loewismannequin
    Mannequin

    Logged In: YES
    user_id=21627

    I'm really not that much concerned about fixing the test,
    but more about fixing the code itself.

  10. mdr0 commented on Mar 10, 2004

    mdr0mannequin
    Mannequin

    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?

  11. devdanzin commented on Feb 13, 2009

    devdanzinmannequin
    Mannequin

    Is this still a problem?

  12. added
    testsTests in the Lib/test dir
    type-bugAn unexpected behavior, bug, or error
    on Feb 13, 2009
  13. 26 remaining items

  14. ritesh006 commented on Sep 1, 2025

    @ritesh006

    Is this issue still relevant in 2025?

  15. mir5903 commented on Oct 23, 2025

    @mir5903

    Is this issue still relevant in 2025?

    Probably not because after that version that attribute have changed

  16. bitdancer commented on Oct 31, 2025

    @bitdancer
    Member

    Looks like it is still relevant:

    >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.

  17. added a commit that references this issue on Nov 1, 2025
  18. added a commit that references this issue on Nov 18, 2025
  19. added 3 commits that reference this issue on Mar 6, 2026
  20. ajm19826 commented on Mar 20, 2026

    @ajm19826

    How is this issue created in 2003?

  21. aiwonderland commented on Mar 29, 2026

    @aiwonderland
  22. added a commit that references this issue on Apr 8, 2026
  23. encukou commented on Apr 8, 2026

    @encukou
    Member

    Thank you for the fix, @Shrey-N!

  24. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13only security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions