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.

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

Created on 2019-10-05 15:04 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16742 merged serhiy.storchaka, 2019-10-13 08:05
Messages (6)
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)
msg375853 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-08-24 16:04
I would prefer "2. Make "out" and "in" positional-only parameters". It would be a minor incompatible change, but it would make os.sendfile() more consistent with other functions like os.write() which only has positional-only parameters.
msg375854 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-08-24 16:06
Well, since os.sendfile(in=fd) raises a syntax error, I don't think that it's really a backward incompatible change in practice.
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82559
2020-08-24 16:06:17vstinnersetmessages: + msg375854
2020-08-24 16:04:40vstinnersetnosy: + vstinner
messages: + msg375853
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