Reputation: 53
I am facing a curious behaviour: assignment unpacking on a 2D vector works perfectly fine, until I subclass it.
$ ipython
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
IPython 5.5.0
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
In [1]: from pygame.math import Vector2
In [2]: a = Vector2(1,1)
In [3]: x,y = a
In [4]: class myvec(Vector2):
...: pass
...:
In [5]: b = myvec(1,1)
In [6]: z,w = b
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
<ipython-input-6-dc661fdbb625> in <module>()
----> 1 z,w = b
SystemError: src/math.c:2954: bad argument to internal function
Can someone help me figure out what is happening here? Is it a pygame bug that I need to report somewhere else, or am I doing something wrong?
Fun fact: it worked perfectly fine for a while, then it suddenly started throwing this exception and there is no going back.
Upvotes: 4
Views: 58
Reputation: 2854
This may not be an answer but I made some checks starting from your example. For instance it does on the surface look like your two classes are at least a little different:
>>> [print(item) for item in dir(a) if item not in dir(b)]
[]
>>> [print(item) for item in dir(b) if item not in dir(a)]
__dict__
__module__
__weakref__
[None, None, None]
so it looks like inheritance does add something even though you're, on the surface, just making a copy of the old class.
So let's look at what the original class looks like from here:
Welp, it's implemented in C. but the error does seem to point to line 2954
:
double *other_coords;
That has me stumped, but I would file this as an issue on the github or wait for the issue fix mentioned in the comment to be rolled out
Upvotes: 1