Open bogdan-kulynych opened 5 years ago
If you compare Bn to anything that is not a Bn...
Bn(42) == "something"
...petlib falls into a recursive death:
Output: AttributeError Traceback (most recent call last) ~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other) 283 try: --> 284 sig = int(_C.BN_cmp(self.bn, other.bn)) 285 return sig AttributeError: 'NotImplementedType' object has no attribute 'bn' During handling of the above exception, another exception occurred: RecursionError Traceback (most recent call last) <ipython-input-2-ea31e540b152> in <module>() ----> 1 Bn(42) == "statast" ~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __eq__(self, other) 294 295 def __eq__(self, other): --> 296 return self.__inner_cmp__(other) == 0 297 298 def __ne__(self, other): ~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other) 285 return sig 286 except AttributeError: --> 287 return self.__inner_cmp__(Bn.from_num(other)) 288 289 def __lt__(self, other): ... last 1 frames repeated, from the frame below ... ~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other) 285 return sig 286 except AttributeError: --> 287 return self.__inner_cmp__(Bn.from_num(other)) 288 289 def __lt__(self, other): RecursionError: maximum recursion depth exceeded while calling a Python object
Nice one!
I ran into the same issue and created this PR to fix it: https://github.com/gdanezis/petlib/pull/26
Just merged the fix -- thanks @ravirahman
If you compare Bn to anything that is not a Bn...
...petlib falls into a recursive death: