classification
Title: os.sendfile() has improperly named parameter
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, giampaolo.rodola, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-10-05 15:04 by serhiy.storchaka, last changed 2019-10-13 09:18 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16742 merged serhiy.storchaka, 2019-10-13 08:05
Messages (4)
msg354012 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-10-05 15:04
os.sendfile() has a keyword-or-positional parameter named "in". Since it is a keyword in Python, it is not possible to pass it as a keyword argument. You can only pass it as a positional argument or using a var-keyword argument (unlikely anybody uses the latter). The preceding parameter, "out", also can not be passed by keyword because of this.

It is weird, but usually does not cause a problem. You cannot use a keyword argument, period. But it prevents os.sendfile() from converting to Argument Clinic, because Argument Clinic does not allow using Python keywords as parameter names (I already created a patch for conversion, but in needs to solve this issue first).

There are two ways to solve this issue.

1. Rename parameter "in" (and maybe "out" for consistency). "out_fd" and "in_fd" look good names (they are use in Linux manpage).

2. Make "out" and "in" positional-only parameters.
msg354013 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-10-05 15:11
See also bpo-15078.
msg354515 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2019-10-12 01:51
I’m for renaming both. Since the function is about transmitting or copying (on Linux) files src_fd and dst_fd could also be good candidates.
msg354571 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-10-13 08:59
New changeset 140a7d1f3579e778656a6b6bfad72489e9870a4d by Serhiy Storchaka in branch 'master':
bpo-38378: Rename parameters "out" and "in" of os.sendfile(). (GH-16742)
https://github.com/python/cpython/commit/140a7d1f3579e778656a6b6bfad72489e9870a4d
History
Date User Action Args
2019-10-13 09:18:44serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-10-13 08:59:36serhiy.storchakasetmessages: + msg354571
2019-10-13 08:05:45serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request16319
2019-10-12 01:51:50giampaolo.rodolasetnosy: + giampaolo.rodola
messages: + msg354515
2019-10-05 15:11:16ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg354013
2019-10-05 15:04:03serhiy.storchakacreate