Commit a417db54 authored by Victor Stinner's avatar Victor Stinner

Merged revisions 83117 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r83117 | victor.stinner | 2010-07-24 03:07:52 +0200 (sam., 24 juil. 2010) | 11 lines

  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).
  ........
................
parent 1270bb9d
...@@ -156,7 +156,7 @@ def do_longs(opts, opt, longopts, args): ...@@ -156,7 +156,7 @@ def do_longs(opts, opt, longopts, args):
if not args: if not args:
raise GetoptError('option --%s requires argument' % opt, opt) raise GetoptError('option --%s requires argument' % opt, opt)
optarg, args = args[0], args[1:] optarg, args = args[0], args[1:]
elif optarg: elif optarg is not None:
raise GetoptError('option --%s must not have an argument' % opt, opt) raise GetoptError('option --%s must not have an argument' % opt, opt)
opts.append(('--' + opt, optarg or '')) opts.append(('--' + opt, optarg or ''))
return opts, args return opts, args
......
...@@ -171,6 +171,12 @@ class GetoptTests(unittest.TestCase): ...@@ -171,6 +171,12 @@ class GetoptTests(unittest.TestCase):
m = types.ModuleType("libreftest", s) m = types.ModuleType("libreftest", s)
run_doctest(m, verbose) 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(): def test_main():
run_unittest(GetoptTests) run_unittest(GetoptTests)
......
...@@ -81,6 +81,10 @@ C-API ...@@ -81,6 +81,10 @@ C-API
Library 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 #7895: platform.mac_ver() no longer crashes after calling os.fork()
- Issue #5395: array.fromfile() would raise a spurious EOFError when an - Issue #5395: array.fromfile() would raise a spurious EOFError when an
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment