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

FileIO.seekable() can return False #49266

Closed
pitrou opened this issue Jan 20, 2009 · 9 comments
Closed

FileIO.seekable() can return False #49266

pitrou opened this issue Jan 20, 2009 · 9 comments
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Jan 20, 2009

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']

    @pitrou
    Copy link
    Member Author

    pitrou commented Jan 20, 2009

    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

    @pitrou pitrou added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Jan 20, 2009
    @vstinner
    Copy link
    Member

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

    @vstinner
    Copy link
    Member

    See also issue bpo-5008.

    @vstinner
    Copy link
    Member

    Woops, I attached the wrong patch!

    @pitrou
    Copy link
    Member Author

    pitrou commented Mar 13, 2009

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

    @vstinner
    Copy link
    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)

    @pitrou
    Copy link
    Member Author

    pitrou commented Mar 27, 2009

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

    @vstinner
    Copy link
    Member

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

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

    @vstinner
    Copy link
    Member

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

    @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
    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

    2 participants