Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid comparisons result in recursive exceptions #22

Open
bogdan-kulynych opened this issue Jul 2, 2019 · 3 comments
Open

Invalid comparisons result in recursive exceptions #22

bogdan-kulynych opened this issue Jul 2, 2019 · 3 comments
Assignees
Labels

Comments

@bogdan-kulynych
Copy link
Contributor

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
@gdanezis gdanezis assigned gdanezis and bogdan-kulynych and unassigned gdanezis Jul 2, 2019
@gdanezis gdanezis added the bug label Jul 2, 2019
@gdanezis
Copy link
Owner

gdanezis commented Jul 2, 2019

Nice one!

@ravirahman
Copy link
Contributor

I ran into the same issue and created this PR to fix it: #26

@gdanezis
Copy link
Owner

Just merged the fix -- thanks @ravirahman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants