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

Misleading error type in draw.circle #2404

Open
yunline opened this issue Aug 17, 2023 · 3 comments · May be fixed by #1842
Open

Misleading error type in draw.circle #2404

yunline opened this issue Aug 17, 2023 · 3 comments · May be fixed by #1842
Labels
bug Not working as intended draw pygame.draw

Comments

@yunline
Copy link
Contributor

yunline commented Aug 17, 2023

>>> import pygame 
pygame-ce 2.4.0.dev1 (SDL 2.26.5, Python 3.10.6)
>>> sf = pygame.Surface((100,100)) 
>>> pygame.draw.circle(sf, "red", (0,0), 1<<33) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: radius argument must be a number
>>>

Should raise an OverflowError here.

@yunline yunline added the bug Not working as intended label Aug 17, 2023
@yunline yunline changed the title pg_IntFromObj pg_IntFromObj ignores overflow error Aug 17, 2023
@yunline yunline changed the title pg_IntFromObj ignores overflow error pg_IntFromObj ignores OverflowError Aug 17, 2023
@yunline yunline changed the title pg_IntFromObj ignores OverflowError Misleading error type in draw.circle Aug 17, 2023
@yunline
Copy link
Contributor Author

yunline commented Aug 17, 2023

Actually, no matter what type of exception is raised inside, it always returns TypeError.

import pygame

class Foo:
    def __index__(self):
        #return 114514
        raise NameError("Foo is not a good name.")
    
sf = pygame.Surface((100,100))

# Expected behavior: raises a NameError
pygame.draw.circle(sf, "red", (0,0), Foo())
Traceback (most recent call last):
  File "x:\python\pygame_test\pgint.py", line 11, in <module>
    pygame.draw.circle(sf, "red", (0,0), Foo())
TypeError: radius argument must be a number

@yunline
Copy link
Contributor Author

yunline commented Aug 17, 2023

When the input is a float, the function doesn't raise any error even if the value is way larger than INT_MAX.

pygame.draw.circle(sf, "red", (0,0), 1e40)
# No Error Raised

@yunline
Copy link
Contributor Author

yunline commented Aug 17, 2023

I'm trying to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended draw pygame.draw
Projects
None yet
2 participants