[Python-checkins] r83116 - in python/branches/py3k: Lib/getopt.py Lib/test/test_getopt.py Misc/NEWS
victor.stinner
python-checkins at python.org
Sat Jul 24 02:49:21 CEST 2010
Author: victor.stinner
Date: Sat Jul 24 02:49:20 2010
New Revision: 83116
Log:
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).
Modified:
python/branches/py3k/Lib/getopt.py
python/branches/py3k/Lib/test/test_getopt.py
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/getopt.py
==============================================================================
--- python/branches/py3k/Lib/getopt.py (original)
+++ python/branches/py3k/Lib/getopt.py Sat Jul 24 02:49:20 2010
@@ -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
Modified: python/branches/py3k/Lib/test/test_getopt.py
==============================================================================
--- python/branches/py3k/Lib/test/test_getopt.py (original)
+++ python/branches/py3k/Lib/test/test_getopt.py Sat Jul 24 02:49:20 2010
@@ -173,6 +173,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)
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Jul 24 02:49:20 2010
@@ -473,6 +473,10 @@
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 #7989: Added pure python implementation of the `datetime`
module. The C module is renamed to `_datetime` and if available,
overrides all classes defined in datetime with fast C impementation.
More information about the Python-checkins
mailing list