[New-bugs-announce] [issue29852] Argument Clinic: add common converter to Py_ssize_t that accepts None

Serhiy Storchaka report at bugs.python.org
Sun Mar 19 07:28:47 EDT 2017


New submission from Serhiy Storchaka:

Many methods in the io module accept int and None and convert the argument to Py_ssize_t. Proposed patch adds common Argument Clinic converter for that case. The Py_ssize_t converter now takes the accept argument that can be {int} (the default) or {int, NoneType}. In the latter case None is acceptable value which means using the default value.

Similar converter was previously used locally in the io module, now it is used also in the mmap module.

Examples:

_io.BytesIO.read
    size: Py_ssize_t(accept={int, NoneType}) = -1
    /

_io.BytesIO.truncate
    size: Py_ssize_t(accept={int, NoneType}, c_default="self->pos") = None
    /

----------
components: Argument Clinic, IO
messages: 289847
nosy: benjamin.peterson, larry, serhiy.storchaka, stutzbach
priority: normal
severity: normal
stage: patch review
status: open
title: Argument Clinic: add common converter to Py_ssize_t that accepts None
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29852>
_______________________________________


More information about the New-bugs-announce mailing list