diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-07-24 01:11:58 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-07-24 01:11:58 (GMT) |
commit | c85ddcd40617238bfc32c5cde79dce7d46fc0946 (patch) | |
tree | 3f75af08a6ad43644027110cccf55fd6169b63ac | |
parent | 1ce4c44b28b430e50ba1632ea7b774e72c0bbc07 (diff) | |
download | cpython-c85ddcd40617238bfc32c5cde79dce7d46fc0946.zip cpython-c85ddcd40617238bfc32c5cde79dce7d46fc0946.tar.gz cpython-c85ddcd40617238bfc32c5cde79dce7d46fc0946.tar.bz2 |
Merged revisions 83116 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83116 | victor.stinner | 2010-07-24 02:49:20 +0200 (sam., 24 juil. 2010) | 4 lines
Issue #4629: getopt raises an error if an argument ends with = whereas getopt
doesn't except a value (eg. --help= is rejected if getopt uses ['help='] long
options).
........
-rw-r--r-- | Lib/getopt.py | 2 | ||||
-rw-r--r-- | Lib/test/test_getopt.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 4 |
3 files changed, 11 insertions, 1 deletions
diff --git a/Lib/getopt.py b/Lib/getopt.py index 13ef4d6..ac77126 100644 --- a/Lib/getopt.py +++ b/Lib/getopt.py @@ -156,7 +156,7 @@ def do_longs(opts, opt, longopts, args): if not args: raise GetoptError('option --%s requires argument' % opt, opt) optarg, args = args[0], args[1:] - elif optarg: + elif optarg is not None: raise GetoptError('option --%s must not have an argument' % opt, opt) opts.append(('--' + opt, optarg or '')) return opts, args diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index 20b5690..f6f9d2e 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -174,6 +174,12 @@ class GetoptTests(unittest.TestCase): m = types.ModuleType("libreftest", s) run_doctest(m, verbose) + def test_issue4629(self): + longopts, shortopts = getopt.getopt(['--help='], '', ['help=']) + self.assertEquals(longopts, [('--help', '')]) + longopts, shortopts = getopt.getopt(['--help=x'], '', ['help=']) + self.assertEquals(longopts, [('--help', 'x')]) + self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help']) def test_main(): run_unittest(GetoptTests) @@ -78,6 +78,10 @@ C-API Library ------- +- Issue #4629: getopt raises an error if an argument ends with = whereas getopt + doesn't except a value (eg. --help= is rejected if getopt uses ['help='] long + options). + - Issue #7895: platform.mac_ver() no longer crashes after calling os.fork() - Issue #9323: Fixed a bug in trace.py that resulted in loosing the |