Skip to content

FileIO.seekable() can return False #49266

Closed

Description

@pitrou
BPO 5016
Nosy @pitrou, @vstinner
Files
  • fileio_seekable-trunk-2.patch
  • 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 2010-09-10.23:22:08.660>
    created_at = <Date 2009-01-20.23:38:37.542>
    labels = ['extension-modules', 'type-bug']
    title = 'FileIO.seekable() can return False'
    updated_at = <Date 2010-09-10.23:22:08.659>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-09-10.23:22:08.659>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-10.23:22:08.660>
    closer = 'vstinner'
    components = ['Extension Modules']
    creation = <Date 2009-01-20.23:38:37.542>
    creator = 'pitrou'
    dependencies = []
    files = ['13433']
    hgrepos = []
    issue_num = 5016
    keywords = ['patch']
    message_count = 9.0
    messages = ['80295', '80301', '80302', '80474', '83545', '84238', '84241', '84246', '116059']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5016'
    versions = ['Python 2.7']

    Activity

    1. pitrou commented on Jan 20, 2009

      @pitrou
      MemberAuthor

      FileIO.seekable() can return False if we first seek to a position such
      that, when truncated to a signed int, it becomes negative:

      >>> f = open('largefile', 'wb', buffering=0)
      >>> f.seek(2**31, 0)
      2147483648
      >>> f.write(b'x')
      1
      >>> f.close()
      >>> f = open('largefile', 'rb', buffering=0)
      >>> f.seek(0, 2)
      2147483649
      >>> f.seekable()
      False
    2. vstinner commented on Jan 21, 2009

      @vstinner
      Member

      Patch with regression test in test_largefile: test 2**31-1, 2**31,
      2**31+1.

    3. vstinner commented on Jan 21, 2009

      @vstinner
      Member

      See also issue bpo-5008.

    4. vstinner commented on Jan 24, 2009

      @vstinner
      Member

      Woops, I attached the wrong patch!

    5. pitrou commented on Mar 13, 2009

      @pitrou
      MemberAuthor

      Committed in r70352 (py3k), r70353 (3.0). Needs backport to trunk and
      2.6, if someone is interested.

    6. vstinner commented on Mar 27, 2009

      @vstinner
      Member

      Needs backport to trunk and 2.6, if someone is interested.

      I'm interrested by a backport at least in trunk. I updated the patch
      to trunk:

      • test directly _file._FileIO() instead of using open() because in
        Python trunk, a file has no seekable() method :-/
      • use contextlib.closing() because _FileIO doesn't implement context
        API (not __exit__() method)
    7. pitrou commented on Mar 27, 2009

      @pitrou
      MemberAuthor

      You can use io.open() instead of open()...

    8. vstinner commented on Mar 27, 2009

      @vstinner
      Member

      You can use io.open() instead of open()...

      Alright, it's much easier with io.open() :-)

    9. vstinner commented on Sep 10, 2010

      @vstinner
      Member

      It is fixed in 2.7 with the backport of the Python3's io library (r73394).

    10. 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

      extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions