Skip to content

talon.ui.Rect.__eq__ throws Attribute Error when one argument is None #191

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

Closed
fmagin opened this issue Dec 26, 2020 · 4 comments
Closed
Labels

Comments

@fmagin
Copy link

fmagin commented Dec 26, 2020

This seems to be a bug introduced with 0.1.3.

Easily reproducible PoC:

from talon.ui import Rect
r = Rect(0,0,1,1)
r == None

Result:

$ .talon/bin/repl
Talon REPL | Python 3.9.1 (default, Dec 11 2020, 06:21:58) [GCC 7.5.0] on linux)
>>> from talon.ui import Rect
>>> r = Rect(0,0,1,1)
>>> r == None
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "talon/skia/rect.py", line 57, in __eq__
AttributeError: 'NoneType' object has no attribute 'x'
>>> None == r
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "talon/skia/rect.py", line 57, in __eq__
AttributeError: 'NoneType' object has no attribute 'x'
@lunixbochs
Copy link

Thanks for the report. I'll fix it. You know you're usually supposed to check "is None" not "== None" when None is an immediate value right?

@lunixbochs
Copy link

Ah, this is otherwise an improvement in 0.1.3. Rects previously had no ==. (And you're still supposed to use is to check against None)

@fmagin
Copy link
Author

fmagin commented Dec 27, 2020

Yes I am aware that you should use is to explicitly check for None, the above was just a simple PoC. The actual code that had this problem was comparing two variables where one was of type r: Rect and the other was t: Optional[Rect]. So my workaround for now is a simple change from r == t to t is not None and r == t.

@lunixbochs
Copy link

fixed in v0.1.4

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

2 participants