From a6c4b1e22cc5223d8eab74fcf814aa04b286b7c7 Mon Sep 17 00:00:00 2001 From: Steven Xu Date: Tue, 7 Jan 2020 21:46:12 +1100 Subject: [PATCH] Supposed to use `sys.stdin` as the `fileobj` when the filename is `'-'`. 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. --- lib/cfv/fileutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cfv/fileutil.py b/lib/cfv/fileutil.py index 1d2ebd0..8db6db7 100644 --- a/lib/cfv/fileutil.py +++ b/lib/cfv/fileutil.py @@ -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: