Skip to content

Commit

Permalink
Supposed to use sys.stdin as the fileobj when the filename is `'-…
Browse files Browse the repository at this point in the history
…'`. Can guess that this is the case from the command line parameters:

    >>> failed test: /home/steven/programming/python/dev/packages/cfv/test/cfv -ZNVRMUI --unquote=no --fixpaths="" --strippaths=0 --showpaths=auto-relative --progress=no --announceurl=url --noprivate_torrent -t bsdmd5 -zz -T -f -  {'stdin': '/tmp/tmpm65hbxli/test.C.bsdmd5.gz'}

This indeed fixes another test (fixes 16 more in total). Not sure why there was a "lovely hack" used previously, but got rid of this hack now.
  • Loading branch information
stevenxxiu committed Jan 7, 2020
1 parent f69e33f commit a6c4b1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cfv/fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def PeekFileNonseekable(fileobj, filename, encoding):
def PeekFileGzip(filename, encoding):
import gzip
if filename == '-':
f = gzip.GzipFile(mode='rb', fileobj=BytesIO()) # lovely hack since gzip.py requires a bunch of seeking.. bleh.
f = gzip.GzipFile(mode='rb', fileobj=sys.stdin)
else:
f = gzip.open(filename, 'rb')
try:
Expand Down

0 comments on commit a6c4b1e

Please sign in to comment.