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.
In my opinion, throwing
ValueErrorforseek(n, SEEK_END)on astream_readeris incorrect. The Pythoniodocs say (for theseekmethod as a whole):To me, this indicates that instead of throwing
ValueError,seek()should throw anOSError. This would fix an issue with passing thestream_readertorequests'dataparameter, which tries to read the length of a file-like object by issuing aSEEK_END, and catchingOSErrororIOErrorto indicate that it is unsupported. Source here.