Whole file

jazzband/docopt-ng

The author described this change as Fix bugs found with language-agnostic tester.. It counts as a record because the checks below fail on the code as it stood at 152d4e13c and pass on e4f9bf1e1, with nothing else changed between the two runs.

Fix saved2012-06-06
Sharing licenceMIT · LICENSE-MIT
Change size+3 2

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

Fix bugs found with language-agnostic tester.

The change

151151 assert argcount in (0, 1)
152152 self.short, self.long = short, long
153153 self.argcount, self.value = argcount, value
154+ self.value = None if value == False and argcount else value # HACK
154155
155156 @classmethod
156157 def parse(class_, option_description):
166167 argcount = 1
167168 if argcount:
168169 matched = re.findall('\[default: (.*)\]', description, flags=re.I)
169- value = matched[0] if matched else False
170+ value = matched[0] if matched else None
170171 return class_(short, long, argcount, value)
171172
172173 def match(self, left, collected=None):
443444 options = [o for o in argv if type(o) is Option]
444445 extras(help, version, options, doc)
445446 formal_pattern = parse_pattern(formal_usage(usage), options=pot_options)
447+ matched, left, arguments = formal_pattern.fix().match(argv)
446448 pot_arguments = [a for a in formal_pattern.flat
447449 if type(a) in [Argument, Command]]
448- matched, left, arguments = formal_pattern.fix().match(argv)
449450 if matched and left == []: # better message if left?
450451 return Dict((a.name, a.value) for a in
451452 (pot_options + options + pot_arguments + arguments))

The check that tells the two apart

failpass·test_docopt.py::test_bug_not_list_argument_if_nothing_matched
failpass·test_docopt.py::test_option_arguments_default_to_none

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 it152d4e13c0a7a7dffb11db87f3f6d5097068d2b8
Broken version dated2012-06-06
Moduledocopt
Units changedOption, docopt
Fingerprint4340315bda6068fc
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