Skip to content

Commit 2f76b56

Browse files
Issue #28102: The zipfile module CLI now prints usage to stderr.
Patch by Stephen J. Turnbull.
1 parent b12881e commit 2f76b56

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Lib/zipfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,19 +1963,19 @@ def main(args = None):
19631963
args = sys.argv[1:]
19641964

19651965
if not args or args[0] not in ('-l', '-c', '-e', '-t'):
1966-
print(USAGE)
1966+
print(USAGE, file=sys.stderr)
19671967
sys.exit(1)
19681968

19691969
if args[0] == '-l':
19701970
if len(args) != 2:
1971-
print(USAGE)
1971+
print(USAGE, file=sys.stderr)
19721972
sys.exit(1)
19731973
with ZipFile(args[1], 'r') as zf:
19741974
zf.printdir()
19751975

19761976
elif args[0] == '-t':
19771977
if len(args) != 2:
1978-
print(USAGE)
1978+
print(USAGE, file=sys.stderr)
19791979
sys.exit(1)
19801980
with ZipFile(args[1], 'r') as zf:
19811981
badfile = zf.testzip()
@@ -1985,15 +1985,15 @@ def main(args = None):
19851985

19861986
elif args[0] == '-e':
19871987
if len(args) != 3:
1988-
print(USAGE)
1988+
print(USAGE, file=sys.stderr)
19891989
sys.exit(1)
19901990

19911991
with ZipFile(args[1], 'r') as zf:
19921992
zf.extractall(args[2])
19931993

19941994
elif args[0] == '-c':
19951995
if len(args) < 3:
1996-
print(USAGE)
1996+
print(USAGE, file=sys.stderr)
19971997
sys.exit(1)
19981998

19991999
def addToZip(zf, path, zippath):

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
Tools/Demos
17+
-----------
18+
19+
- Issue #28102: The zipfile module CLI now prints usage to stderr.
20+
Patch by Stephen J. Turnbull.
21+
1622

1723
What's New in Python 3.6.0 beta 1
1824
=================================

0 commit comments

Comments
 (0)