Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.sendfile() has improperly named parameter #82559

Closed
serhiy-storchaka opened this issue Oct 5, 2019 · 6 comments
Closed

os.sendfile() has improperly named parameter #82559

serhiy-storchaka opened this issue Oct 5, 2019 · 6 comments
Labels
3.9 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 38378
Nosy @vstinner, @giampaolo, @serhiy-storchaka, @ZackerySpytz
PRs
  • bpo-38378: Rename parameters "out" and "in" of os.sendfile(). #16742
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-10-13.09:18:44.343>
    created_at = <Date 2019-10-05.15:04:03.222>
    labels = ['extension-modules', 'type-bug', '3.9']
    title = 'os.sendfile() has improperly named parameter'
    updated_at = <Date 2020-08-24.16:06:17.474>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-08-24.16:06:17.474>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-10-13.09:18:44.343>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2019-10-05.15:04:03.222>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38378
    keywords = ['patch']
    message_count = 6.0
    messages = ['354012', '354013', '354515', '354571', '375853', '375854']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'giampaolo.rodola', 'serhiy.storchaka', 'ZackerySpytz']
    pr_nums = ['16742']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38378'
    versions = ['Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Oct 5, 2019
    @ZackerySpytz
    Copy link
    Mannequin

    ZackerySpytz mannequin commented Oct 5, 2019

    See also bpo-15078.

    @giampaolo
    Copy link
    Contributor

    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.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 140a7d1 by Serhiy Storchaka in branch 'master':
    bpo-38378: Rename parameters "out" and "in" of os.sendfile(). (GH-16742)
    140a7d1

    @vstinner
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member

    Well, since os.sendfile(in=fd) raises a syntax error, I don't think that it's really a backward incompatible change in practice.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants