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.

Author eryksun
Recipients eryksun, jkloth, vstinner
Date 2022-02-13.08:21:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644740489.41.0.434020781195.issue46716@roundup.psfhosted.org>
In-reply-to
Content
> the fix should be as simple as coercing the timeout values to >= 0.

Popen._remaining_time() should return max(endtime - _time(), 0).

Popen._wait() should raise OverflowError if the timeout is too large for the implementation. In Windows, the upper limit in milliseconds is `_winapi.INFINITE - 1` (about 49.7 days). It's important to only allow the timeout in milliseconds to be _winapi.INFINITE when `timeout is None`.

The DWORD converter in _winapi needs to subclass unsigned_long_converter. The current implementation based on the legacy format unit "k" is too lenient. Negative values and values that are too large should fail. I updated it to use the following definition:

    class DWORD_converter(unsigned_long_converter):
        type = 'DWORD'

This produces the following improved results:

    >>> h = _winapi.GetCurrentProcess()
    >>> _winapi.WaitForSingleObject(h, _winapi.INFINITE + 1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: Python int too large to convert to C unsigned long

    >>> _winapi.WaitForSingleObject(h, -1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: value must be positive
History
Date User Action Args
2022-02-13 08:21:29eryksunsetrecipients: + eryksun, vstinner, jkloth
2022-02-13 08:21:29eryksunsetmessageid: <1644740489.41.0.434020781195.issue46716@roundup.psfhosted.org>
2022-02-13 08:21:29eryksunlinkissue46716 messages
2022-02-13 08:21:29eryksuncreate