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

subclassing the math.Vector2 class results in Fatal Error #552

Closed
christianpostprivate opened this issue Oct 9, 2018 · 2 comments
Closed

subclassing the math.Vector2 class results in Fatal Error #552

christianpostprivate opened this issue Oct 9, 2018 · 2 comments

Comments

@christianpostprivate
Copy link

@christianpostprivate christianpostprivate commented Oct 9, 2018

When I make a subclass of pygame.math.Vector2 and do a scalar multiplication, it results in a crash and a Fatal Error

import pygame

class Vector(pygame.math.Vector2):
    pass

# this stuff works fine
vec_a = Vector(2, 0)
vec_b = Vector(0, 1)

print(vec_a + vec_b)
print(vec_a.length())
print(vec_a.normalize())

vec_c = vec_a.rotate(90)
print(vec_c)

# but this raises the Error
vec_a *= 2

The Error message I get is

Fatal Python error: (pygame parachute) Segmentation Fault

Reproducability: I only tried this on two Windows 7 PCs with python 3.6 and in Spyder. Pygame Version is 1.9.3

Also someone on reddit said they got the same error
https://www.reddit.com/r/learnpython/comments/9mnu4b/making_an_existing_class_hashable_pygame_vector/

@illume
Copy link
Member

@illume illume commented Oct 9, 2018

Thanks :) I guess the *= part is just using a hardcoded self, when it probably has to do a more complicated lookup because of the inheritance.

Would it be possible to submit a pull request with this as a unit test? https://www.pygame.org/contribute.html

Loading

@illume illume added this to the 1.9.5 milestone Oct 9, 2018
sw00 added a commit to sw00/pygame that referenced this issue Oct 14, 2018
cmtrapp02 added a commit to cmtrapp02/pygame that referenced this issue Oct 15, 2018
Added new function that tests a subclassed math.Vector2 for issue pygame#552.
This is my first contribution on Github, so any feedback if necessary would be greatly appreciated!
illume added a commit that referenced this issue Oct 16, 2018
Added math.Vector2 subclass test for issue #552
@illume illume closed this in c39ddee Oct 16, 2018
@PietroPasotti
Copy link

@PietroPasotti PietroPasotti commented Mar 18, 2019

When is this going to be fixed? I am having some related issues

Loading

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

Successfully merging a pull request may close this issue.

None yet
3 participants