diff -r 0c8ffa562f3a Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py Wed Nov 02 12:13:48 2016 +0200 +++ b/Lib/test/test_zipfile.py Wed Nov 02 20:25:26 2016 +0200 @@ -2053,6 +2053,16 @@ class CommandLineTest(unittest.TestCase) def zipfilecmd_failure(self, *args): return script_helper.assert_python_failure('-m', 'zipfile', *args) + def test_bad_use(self, *args): + rc, out, err = self.zipfilecmd_failure() + self.assertEqual(out, b'') + self.assertIn(b'usage', err.lower()) + self.assertIn(b'error', err.lower()) + self.assertIn(b'required', err.lower()) + rc, out, err = self.zipfilecmd_failure('-l', '') + self.assertEqual(out, b'') + self.assertNotEqual(err.strip(), b'') + def test_test_command(self): zip_name = findfile('zipdir.zip') for opt in '-t', '--test': diff -r 0c8ffa562f3a Lib/zipfile.py --- a/Lib/zipfile.py Wed Nov 02 12:13:48 2016 +0200 +++ b/Lib/zipfile.py Wed Nov 02 20:25:26 2016 +0200 @@ -1953,9 +1953,9 @@ class PyZipFile(ZipFile): def main(args=None): import argparse - description = 'A simple command line interface for zipfile module.' + description = 'A simple command-line interface for zipfile module.' parser = argparse.ArgumentParser(description=description) - group = parser.add_mutually_exclusive_group() + group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-l', '--list', metavar='', help='Show listing of a zipfile') group.add_argument('-e', '--extract', nargs=2, @@ -2010,8 +2010,5 @@ def main(args=None): zippath = '' addToZip(zf, path, zippath) - else: - parser.exit(2, parser.format_usage()) - if __name__ == "__main__": main()