def file_length(file_obj):
file_obj.seek(<NUM_LIT:0>, <NUM_LIT:2>)<EOL>length = file_obj.tell()<EOL>file_obj.seek(<NUM_LIT:0>)<EOL>return length<EOL>
Returns the length in bytes of a given file object.
Necessary because os.fstat only works on real files and not file-like
objects. This works on more types of streams, primarily StringIO.