Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid comparisons result in recursive exceptions #22

@bogdan-kulynych

Description

@bogdan-kulynych

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

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions