New submission from Giampaolo Rodola' <g.rod...@gmail.com>:

>>> import resource
    >>> high = 300 * 1024 * 1024
    >>> resource.setrlimit(resource.RLIMIT_MEMLOCK, (high, high))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: not allowed to raise maximum limit
    >>> 

Internally EPERM is translated into ValueError (should have been 
PermissionError). resource.prlimit(), on the other hand, is not affected 
(correctly raises PermissionError):

    >>> resource.prlimit(os.getpid(), resource.RLIMIT_MEMLOCK, (high, high))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    PermissionError: [Errno 1] Operation not permitted


It seems 'ValueError' was used in order to provide a more informative error 
message, but IMO it was a bad call.
Proposal is to change this in 3.9 only, and document it under whatsnew/porting.

----------
components: Library (Lib)
messages: 354701
nosy: giampaolo.rodola
priority: normal
severity: normal
status: open
title: resource.setrlimit() should raise PermissionError
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38480>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to