One function

PrefixSet in mina86/pygtrie

The author described this change as Fix PrefixSet.copy method. It counts as a record because the check below fails on the code as it stood at 905f8c7da and passes on 344a414dd, with nothing else changed between the two runs.

Fix saved2018-08-10
Sharing licenceApache-2.0 · LICENSE
Change size+1 1

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

A set of prefixes. :class:`pygtrie.PrefixSet` works similar to a normal set except it is said to contain a key if the key or it's prefix is stored in the set. For instance, if "foo" is added to the set, the set contains "foo" as well as "foobar". The set supports addition of elements but does *not* support removal of elements. This is because there's no obvious consistent and intuitive behaviour for element deletion.

The change

2727
2828 def copy(self):
2929 """Returns a copy of the prefix set."""
30- return self.__class__(self._trie)
30+ return self.__class__(self._trie, factory=self._trie.__class__)
3131
3232 def clear(self):
3333 """Removes all keys from the set."""

The check that tells the two apart

failpass·test.py::CharTrieTestCase::test_prefix_set

Check file test.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 it905f8c7da2bfe66e3fc32ece95ba84c5b8d3817e
Broken version dated2018-08-07
Modulepygtrie
Units changedPrefixSet
Fingerprinta601732584b24c9a
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 mina86/pygtrie