Closed zorun closed 8 years ago
Thanks for this. Yes, I agree that KeyError would be sensible in that case, and I'm sure there are other situations where exceptions are not being thrown as should be expected. I'll get to this when I can.
The obvious occurrences are fixed. Please re-open if you find any additional occurrences --- thanks.
This happens for the loopback version of IPv6 (i.e. ::1
). Both when inserting and searching.
>>> import pytricia
>>> tree = pytricia.PyTricia(128)
>>> tree["::1"] = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: error return without exception set
>>> tree["::1"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid prefix.
It works fine with ::1/128
though.
There seems to be some error cases where methods exit with a NULL pointer, but no exception is defined. This results in a SystemError exception, which is surprising to the user:
In this case, a KeyError exception would be expected.
This seems related to the prefix parsing code, but there may be other places as well.