Skip to content

Avoid raising OverflowError in truncate() if possible #74005

Description

@serhiy-storchaka
BPO 29819
Nosy @vstinner, @benjaminp, @serhiy-storchaka, @orenmn, @nanjekyejoannah
Dependencies
  • bpo-29852: Argument Clinic: add common converter to Py_ssize_t that accepts None
  • 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 = None
    created_at = <Date 2017-03-15.15:11:06.614>
    labels = ['3.7', 'type-feature', 'library', 'expert-IO']
    title = 'Avoid raising OverflowError in truncate() if possible'
    updated_at = <Date 2019-05-27.16:44:36.338>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-05-27.16:44:36.338>
    actor = 'nanjekyejoannah'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'IO']
    creation = <Date 2017-03-15.15:11:06.614>
    creator = 'serhiy.storchaka'
    dependencies = ['29852']
    files = []
    hgrepos = []
    issue_num = 29819
    keywords = []
    message_count = 2.0
    messages = ['289677', '289848']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'benjamin.peterson', 'stutzbach', 'serhiy.storchaka', 'Oren Milman', 'nanjekyejoannah']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue29819'
    versions = ['Python 3.7']

    Activity

    1. serhiy-storchaka commented on Mar 15, 2017

      @serhiy-storchaka
      MemberAuthor

      os.truncate(), os.ftruncate() and truncate() methods of file-like objects raise OverflowError when the argument is out of ranger of certain C type. It would be better to extend the behavior of small integers to large integers. ValueError is raised for negative integers and it should be raised for negative integers out of range. Values larger than the current size should be ignored in BytesIO.truncate() and StringIO.truncate(). BytesIO.truncate() and StringIO.truncate() should never raise OverflowError. Since the behavior of underlying OS functions is OS and FS depended, OverflowError can be raised for large integers in os.truncate(), os.ftruncate() and FileIO.truncate().

    2. serhiy-storchaka commented on Mar 19, 2017

      @serhiy-storchaka
      MemberAuthor

      bpo-29852 is not strict dependency, but it may make the solution of this issue simpler.

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytopic-IOtype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions