Index: Lib/getopt.py =================================================================== --- Lib/getopt.py (révision 70631) +++ Lib/getopt.py (copie de travail) @@ -156,7 +156,7 @@ 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 Index: Lib/test/test_getopt.py =================================================================== --- Lib/test/test_getopt.py (révision 70631) +++ Lib/test/test_getopt.py (copie de travail) @@ -176,6 +176,12 @@ 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)