Whole file
kmike/DAWG-Python
The author described this change as “bug with empty dawgs is fixed”. It counts as a record because the check below fails on the code as it stood at f505de91f and passes on 5abda1b18, with nothing else changed between the two runs.
Projectkmike/DAWG-Python
Fix saved2012-10-01
Sharing licenceMIT · LICENSE
Change size+10 −2
What the code was meant to do, written into the code itself as a save note
bug with empty dawgs is fixed
The change
| 92 | 92 | base_size = struct.unpack(str("=I"), fp.read(4))[0] | |
| 93 | 93 | self._units = bytearray(fp.read(base_size*2)) | |
| 94 | 94 | ||
| 95 | + | def size(self): | |
| 96 | + | return len(self._units) if self._units is not None else 0 | |
| 95 | 97 | ||
| 98 | + | ||
| 96 | 99 | class Completer(object): | |
| 97 | 100 | ||
| 98 | 101 | def __init__(self, dic=None, guide=None): | |
| ⋯ | |||
| 104 | 107 | ||
| 105 | 108 | def start(self, index, prefix=b""): | |
| 106 | 109 | self.key = bytearray(prefix) | |
| 107 | - | self._index_stack = [index] | |
| 108 | - | self._last_index = self._dic.root() | |
| 110 | + | ||
| 111 | + | if self._guide.size(): | |
| 112 | + | self._index_stack = [index] | |
| 113 | + | self._last_index = self._dic.root() | |
| 114 | + | else: | |
| 115 | + | self._index_stack = [] | |
| 116 | + | ||
| 109 | 117 | ||
| 110 | 118 | def next(self): | |
| 111 | 119 | "Gets the next key" | |
The check that tells the two apart
fail→pass·tests/test_dawg.py::TestCompletionDAWG::test_empty_dawg
Check file tests/test_dawg.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 itf505de91f33d491e46c36d8c96889ebc413de9c4
Broken version dated2012-09-26
Moduledawg_python.wrapper
Units changedCompleter, Guide
Fingerprintddf208060b5f2b66
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.