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.

classification
Title: Argument Clinic: add common converter to Py_ssize_t that accepts None
Type: enhancement Stage: resolved
Components: Argument Clinic, IO Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, larry, serhiy.storchaka, stutzbach
Priority: normal Keywords:

Created on 2017-03-19 11:28 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 716 merged serhiy.storchaka, 2017-03-19 11:37
Messages (2)
msg289847 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-19 11:28
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
    /
msg290821 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-30 06:15
New changeset 762bf40438a572a398e500c74e38f9894ea20a45 by Serhiy Storchaka in branch 'master':
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
https://github.com/python/cpython/commit/762bf40438a572a398e500c74e38f9894ea20a45
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74038
2017-03-30 06:20:11serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-03-30 06:15:34serhiy.storchakasetmessages: + msg290821
2017-03-19 11:37:31serhiy.storchakasetpull_requests: + pull_request636
2017-03-19 11:35:57serhiy.storchakalinkissue29819 dependencies
2017-03-19 11:28:47serhiy.storchakacreate