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

Update math.c #360

Merged
merged 2 commits into from
Feb 6, 2018
Merged

Update math.c #360

merged 2 commits into from
Feb 6, 2018

Conversation

stuaxo
Copy link
Contributor

@stuaxo stuaxo commented Sep 27, 2017

Replace ob_item access in math.c with macros so pygame compiles in pypy.

(Thanks to Armin Rigo of Pypy for suggesting how to do this).

With this change, pygame seems to work in pypy.

I tried all the examples, the only problems seemed to be:

Errors on any keyboard events e.g.

Traceback (most recent call last):
  File "aliens.py", line 321, in <module>
    if __name__ == '__main__': main()
  File "aliens.py", line 257, in main
    (event.type == KEYDOWN and event.key == K_ESCAPE):
AttributeError: 'Event' object has no attribute 'key'

The fastevents example seemed to be frozen, all the examples displayed graphics and played sounds.

Replace ob_item access in math.c with macros so pygame compiles in pypy.

(Thanks to Armin Rigo of Pypy for suggesting how to do this).

With this change, pygame seems to work in pypy.

I tried all the examples, the only problems seemed to be:

Errors on any keyboard events e.g.

```
Traceback (most recent call last):
  File "aliens.py", line 321, in <module>
    if __name__ == '__main__': main()
  File "aliens.py", line 257, in main
    (event.type == KEYDOWN and event.key == K_ESCAPE):
AttributeError: 'Event' object has no attribute 'key'
```

The fastevents example seemed to be frozen, all the examples displayed graphics and played sounds.
@stuaxo
Copy link
Contributor Author

stuaxo commented Sep 27, 2017

One failure is unrelated -

AssertionError: Failed to access the SoundFont /usr/share/sounds/sf2/FluidR3_GM.sf2

I'm not sure why the segfault in the math tests is happening, can't reproduce it myself right now.

@stuaxo
Copy link
Contributor Author

stuaxo commented Sep 27, 2017

Have reproduced it.. I guess not knowing the CPython API doesn't help here..

Fix use of PyList_SET_ITEM
@stuaxo
Copy link
Contributor Author

stuaxo commented Sep 27, 2017

My lack of C knowledge showing there.

Now, all the math tests pass under pypy except

.......................................................F...........................
======================================================================
FAIL: testSwizzle (__main__.Vector3TypeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/math_test.py", line 1331, in testSwizzle
    self.assertRaises(AttributeError, invalidSwizzleW)
AssertionError: AttributeError not raised

----------------------------------------------------------------------
Ran 83 tests in 0.020s

FAILED (failures=1)

NOTE - you need to first apply the cython patch in my other pull request for this to work.

@illume illume closed this Feb 6, 2018
@illume illume reopened this Feb 6, 2018
@illume
Copy link
Member

illume commented Feb 6, 2018

PyList_SET_ITEM seems fine, since it's a new list.

It's interesting that it gets all the way to self.assertRaises(AttributeError, invalidSwizzleW) Since the tests just before that seem to do pretty much the same thing.

@illume
Copy link
Member

illume commented Feb 6, 2018

I guess this i should be idx. entry[idx] = PySequence_GetItem_AsDouble(val, i); in vector_setAttr_swizzle. The names should probably be fixed to be a bit more descriptive.

@illume illume merged commit b67b21c into pygame:master Feb 6, 2018
@stuaxo
Copy link
Contributor Author

stuaxo commented Feb 6, 2018

Cheers.

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

Successfully merging this pull request may close these issues.

2 participants