This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add deprecation of float limits for resource to documentation
Type: Stage:
Components: Versions: Python 3.10, Python 3.9, Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, nafur, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-02-02 12:52 by nafur, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg386139 - (view) Author: Gereon Kremer (nafur) * Date: 2021-02-02 12:52
While the documentation always (as in: at least since 3.5) required to pass "a tuple (soft, hard) of two integers" to resource.setrlimit(), passing floats worked just fine until 3.9.
This behavior was deprecated in 3.8 and removed in 3.10.

I see that the implementation was merely fixed to do what the documentation says. Nevertheless, I think this change of behavior should be mentioned in the documentation.

In my use-case for resource (within preexec_fn of subprocess.Popen), this deprecation warning only showed up in 3.9 for some reason (as you can see here: and is now hidden by a generic "subprocess.SubprocessError: Exception occurred in preexec_fn." message.
A hint in the documentation would have helped significantly...
msg386636 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-02-08 17:41
This change was indirectly documented in What's New for 3.8 (deprecation)

Functions that convert Python number to C integer like PyLong_AsLong() and argument parsing functions like PyArg_ParseTuple() with integer converting format units like 'i' will now use the __index__() special method instead of __int__(), if available. The deprecation warning will be emitted for objects with the __int__() method but without the __index__() method (like Decimal and Fraction). PyNumber_Check() will now return 1 for objects implementing __index__(). PyNumber_Long(), PyNumber_Float() and PyFloat_AsDouble() also now use the __index__() method if available.

and for 3.10 (removing)

Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the __int__() method but do not have the __index__() method).

It was impractical to document it for every affected function, because there may be many tens of such functions in the stdlib, and it is difficult to find all functions which directly or indirectly use PyLong_AsLong() and similar C API. In any case accepting non-integer numbers was not intentional.
msg386637 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-02-08 17:55
Agreed with Serhiy that it's not practical to document all the affected functions.
msg386643 - (view) Author: Gereon Kremer (nafur) * Date: 2021-02-08 18:40
Hm, I see.

For methods that do not intercept exceptions or run code in a different process or alike, the deprecation warning and the TypeError should be sufficient.

Given that identifying this issue can be particularly nasty for setrlimit (if used within preexec_fn), could we document this particular affected function anyway?
msg386644 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-02-08 19:08
Maybe the better fix is to have better reporting of the `preexec_fn` error, so that it's not entirely hidden by the `SubprocessError`? On the other hand, given that `preexec_fn` may be going away entirely soon (see #38435), that may not be worth it.
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87267
2021-02-08 19:08:11mark.dickinsonsetmessages: + msg386644
2021-02-08 18:40:37nafursetmessages: + msg386643
2021-02-08 17:55:17mark.dickinsonsetmessages: + msg386637
2021-02-08 17:41:16serhiy.storchakasetnosy: + mark.dickinson
messages: + msg386636
2021-02-02 12:55:47rhettingersetnosy: + serhiy.storchaka
2021-02-02 12:52:41nafurcreate