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

Update os.pread to accept the length type as size_t #82446

Closed
corona10 opened this issue Sep 24, 2019 · 11 comments
Closed

Update os.pread to accept the length type as size_t #82446

corona10 opened this issue Sep 24, 2019 · 11 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@corona10
Copy link
Member

BPO 38265
Nosy @vstinner, @serhiy-storchaka, @corona10
PRs
  • bpo-38265: Update os.pread to accept the length type as Py_ssize_t #16359
  • 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-09-25.11:14:19.644>
    created_at = <Date 2019-09-24.18:14:15.456>
    labels = ['library', '3.9']
    title = 'Update os.pread to accept the length type as size_t'
    updated_at = <Date 2019-09-25.11:53:20.902>
    user = 'https://github.com/corona10'

    bugs.python.org fields:

    activity = <Date 2019-09-25.11:53:20.902>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-25.11:14:19.644>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2019-09-24.18:14:15.456>
    creator = 'corona10'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38265
    keywords = ['patch']
    message_count = 11.0
    messages = ['353107', '353108', '353109', '353110', '353111', '353143', '353144', '353166', '353172', '353174', '353183']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'serhiy.storchaka', 'corona10']
    pr_nums = ['16359']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue38265'
    versions = ['Python 3.9']

    @corona10
    Copy link
    Member Author

    I've found this comments.
    // TODO length should be size_t! but Python doesn't support parsing size_t yet.
    (

    # TODO length should be size_t! but Python doesn't support parsing size_t yet.
    )

    I don't know when this comment was created.
    But at this point, it seems to provide that functionality.
    It can be simply solved through the clinic.

    How about updating this argument to be size_t and remove the TODO comment?

    @corona10 corona10 added 3.9 only security fixes stdlib Python modules in the Lib dir labels Sep 24, 2019
    @serhiy-storchaka
    Copy link
    Member

    Length should be Py_ssize_t. Python does not support creating bytes objects larger than PY_SSIZE_T_MAX.

    @corona10
    Copy link
    Member Author

    Oh okay!
    Thanks for letting me know.
    Is it okay to switch it into Py_ssize_t?

    @serhiy-storchaka
    Copy link
    Member

    I think it is okay. Just check that all platforms which support pread() (Linux, *BSD, macOS) pass the length as size_t instead of int. Windows does not always support length larger than 2 KiB, but it does not support pread() either.

    @corona10
    Copy link
    Member Author

    @serhiy-storchaka
    Copy link
    Member

    New changeset ad7736f by Serhiy Storchaka (Dong-hee Na) in branch 'master':
    bpo-38265: Update os.pread to accept the length type as Py_ssize_t. (GH-16359)
    ad7736f

    @corona10
    Copy link
    Member Author

    Thank you @serhiy.storchaka and Kyle Stanley for the code review and approve.

    This issue is now solved.
    I close this issue.

    @vstinner
    Copy link
    Member

    Python 3.7 and 3.8 also have os.pread(). Why not also fixing these branches?

    --

    os.pwrite() uses Py_buffer for its argument and supports size_t size.

    os.preadv() and os.pwritev() use internally the C structure "struct iovec" which uses size_t for its iov_len field.

    @vstinner vstinner reopened this Sep 25, 2019
    @serhiy-storchaka
    Copy link
    Member

    Because this looks rather as a new feature than a bug fix. We don't add new features in maintained versions.

    Always there is a risk of introducing a regression. We don't know what bugs are contained in 64-bit size support on different platforms. I would not be surprised if for example some old macOS versions accept size_t, but work correctly only with the 32-bit size.

    @vstinner
    Copy link
    Member

    Because this looks rather as a new feature than a bug fix. We don't add new features in maintained versions.

    Oh ok. That's fair. I close the issue.

    The workaround is to use os.preadv() or other functions which accept size_t.

    @serhiy-storchaka
    Copy link
    Member

    Or call pread() multiple times and concatenate results.

    @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 stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants