◐ Shell
clean mode source ↗

Message 186970 - Python tracker

Okay, I got inspired and (in the words of Barry Warsaw) JFDI.  Attached is my revised patch.  I took Serhiy's patch and reworked it quite a bit:

* I think it's now easier to follow.  In particular:
* The most common case (no overflow) is now first.  In Serhiy's patch
  the most common case is buried in the middle of the second "if".
* I removed some extraneous tests.
* I changed the error messages to call the values "uid" and "gid", to match the names of the parameters.
* I noticed that _fd_converter had the same bad-idea PyFloat_Check, so I changed it to use PyNumber_Index instead.

In the process I also noticed that Serhiy's approach had a resource leak: it never decref'd the result of PyNumber_Index() when successful.

To make sure I duplicated Serhiy's semantics, I had a test harness that ran both his and mine and ensured they returned the same thing (or both threw an error).  Obviously I removed all that before cutting the patch.