Skip to content

Throw a more correct exception for SEEK_END #107

@octylFractal

Description

@octylFractal

In my opinion, throwing ValueError for seek(n, SEEK_END) on a stream_reader is incorrect. The Python io docs say (for the seek method as a whole):

Return True if the stream supports random access. If False, seek(), tell() and truncate() will raise OSError.

To me, this indicates that instead of throwing ValueError, seek() should throw an OSError. This would fix an issue with passing the stream_reader to requests' data parameter, which tries to read the length of a file-like object by issuing a SEEK_END, and catching OSError or IOError to indicate that it is unsupported. Source here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions