cyac
cyac copied to clipboard
Segmentation fault when iterating over AC trie
Issue
When iterating over an AC trie, a segmentation fault occurs. For example:
import cyac
trie = cyac.AC.build(['hello', 'world'])
for w in trie:
print(w)
Output:
hello
world
Segmentation fault
However, AC.items() is works as expected.
Environment
- Ubuntu 18.04
- Python 3.6.9
- Cython 0.29.21
- cyac 1.4
it seems that it's cython's bug. AC has not implemented iter method. In my python environment, your code complains:
lib/cyac/ac.pyx in cyac.ac.AC.__getitem__()
lib/cyac/trie.pyx in cyac.trie.Trie.__getitem__()
AttributeError: 'NoneType' object has no attribute 'decode'
@stephankoe please try this branch. https://github.com/nppoly/cyac/pull/14
Yes, that branch is working. Thanks!