Whole file

jazzband/docopt-ng

The author described this change as Fix bug when user error was shown in case of developer error.. It counts as a record because the check below fails on the code as it stood at 1d9152082 and passes on e5e4a8983, with nothing else changed between the two runs.

Fix saved2012-06-12
Sharing licenceMIT · LICENSE-MIT
Change size+6 6

What the code was meant to do, written into the code itself as a save note

Fix bug when user error was shown in case of developer error.

The change

424424 if help and any((o.name in ('-h', '--help')) and o.value for o in options):
425425 print(doc.strip())
426426 exit()
427- if version and any(o.long == '--version' and o.value for o in options):
427+ if version and any(o.name == '--version' and o.value for o in options):
428428 print(version)
429429 exit()
430430
437437 def docopt(doc, argv=sys.argv[1:], help=True, version=None):
438438 DocoptExit.usage = docopt.usage = usage = printable_usage(doc)
439439 pot_options = parse_doc_options(doc)
440- argv = parse_args(argv, options=pot_options)
441- options = [o for o in argv if type(o) is Option]
442- extras(help, version, options, doc)
443440 formal_pattern = parse_pattern(formal_usage(usage), options=pot_options)
441+ argv = parse_args(argv, options=pot_options)
442+ extras(help, version, argv, doc)
444443 matched, left, arguments = formal_pattern.fix().match(argv)
445- pot_arguments = [a for a in formal_pattern.flat
446- if type(a) in [Argument, Command]]
447444 if matched and left == []: # better message if left?
445+ options = [o for o in argv if type(o) is Option]
446+ pot_arguments = [a for a in formal_pattern.flat
447+ if type(a) in [Argument, Command]]
448448 return Dict((a.name, a.value) for a in
449449 (pot_options + options + pot_arguments + arguments))
450450 raise DocoptExit()

The check that tells the two apart

failpass·test_docopt.py::test_long_options_error_handling

Check file test_docopt.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it1d9152082fa7b6d3fae43b45ac216f716f1cd53f
Broken version dated2012-06-11
Moduledocopt
Units changeddocopt, extras
Fingerprinte8fa0c56303b6a19
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in jazzband/docopt-ng