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.
Projectjazzband/docopt-ng
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
| 151 | 151 | assert argcount in (0, 1) | |
| 152 | 152 | self.short, self.long = short, long | |
| 153 | 153 | self.argcount, self.value = argcount, value | |
| 154 | + | self.value = None if value == False and argcount else value # HACK | |
| 154 | 155 | ||
| 155 | 156 | @classmethod | |
| 156 | 157 | def parse(class_, option_description): | |
| ⋯ | |||
| 166 | 167 | argcount = 1 | |
| 167 | 168 | if argcount: | |
| 168 | 169 | matched = re.findall('\[default: (.*)\]', description, flags=re.I) | |
| 169 | - | value = matched[0] if matched else False | |
| 170 | + | value = matched[0] if matched else None | |
| 170 | 171 | return class_(short, long, argcount, value) | |
| 171 | 172 | ||
| 172 | 173 | def match(self, left, collected=None): | |
| ⋯ | |||
| 443 | 444 | options = [o for o in argv if type(o) is Option] | |
| 444 | 445 | extras(help, version, options, doc) | |
| 445 | 446 | formal_pattern = parse_pattern(formal_usage(usage), options=pot_options) | |
| 447 | + | matched, left, arguments = formal_pattern.fix().match(argv) | |
| 446 | 448 | pot_arguments = [a for a in formal_pattern.flat | |
| 447 | 449 | if type(a) in [Argument, Command]] | |
| 448 | - | matched, left, arguments = formal_pattern.fix().match(argv) | |
| 449 | 450 | if matched and left == []: # better message if left? | |
| 450 | 451 | return Dict((a.name, a.value) for a in | |
| 451 | 452 | (pot_options + options + pot_arguments + arguments)) | |
The check that tells the two apart
fail→pass·test_docopt.py::test_bug_not_list_argument_if_nothing_matched
fail→pass·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.