python-midi
python-midi copied to clipboard
Python 3 support, continued
This is a continuation of @florianfesti's excellent PR #35. It fixes some bugs and made the test suite pass on Pythons 2 and 3 on my machine.
I believe I've figured out how to raise exceptions in C code that is wrapped by SWIG. Now the tests fail because you cannot open /dev/snd/seq in the Travis environment.
What's a bit more annoying is that tests fail for me locally with
======================================================================
ERROR: test_loopback_sequencer (tests.TestSequencerALSA)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mg/src/python-midi/tests/tests.py", line 76, in test_loopback_sequencer
recv_event = rseq.event_read()
File "/home/mg/src/python-midi/.tox/py27/local/lib/python2.7/site-packages/midi/sequencer/sequencer.py", line 278, in event_read
ev = S.event_input(self.client)
IOError: Resource temporarily unavailable
I don't know how the ALSA loopback sequencer is supposed to work, so I'm not sure how to debug this.
Coverage increased (+0.1%) to 68.201% when pulling d0d01c4f995b04710488ea9dfce62bbe1334c5ab on mgedmin:python3 into 4b7a229f6b340e7424c1fccafa9ac543b9b3d605 on vishnubob:master.
Coverage increased (+0.2%) to 68.212% when pulling d0d01c4f995b04710488ea9dfce62bbe1334c5ab on mgedmin:python3 into 4b7a229f6b340e7424c1fccafa9ac543b9b3d605 on vishnubob:master.
And I've figured out that the Resource temporarily unavailable error is normal and should be ignored, and now all three tests pass on my machine!
I think this is ready for merging. I'd appreciate if any other users cared to test this branch on either Python 2 or 3.
Coverage increased (+0.1%) to 68.201% when pulling fbde41048050f780ba8801f7b65c4e0d5ec2c53d on mgedmin:python3 into 4b7a229f6b340e7424c1fccafa9ac543b9b3d605 on vishnubob:master.
Coverage increased (+0.1%) to 68.201% when pulling fec1e8fdf4eae248612b9843a599956ebaccdb77 on mgedmin:python3 into 4b7a229f6b340e7424c1fccafa9ac543b9b3d605 on vishnubob:master.
Godspeed!
Sorry, I thought I could review single patches. So my review above is premature. Will look through the other patches now.
After looking through all patches: This looks really good. I strongly support merging this PR.
One might argue that it might be even better if the two or three patches that fix previous ones would be rebased and squashed but this is rather cosmetic. Candidates might be:
- Include own copy of with_metaclass()
- Python 2 iterator protocol compatibility which could be merged with my patches that create the issues in the first place and
- Fix compiler warning about incompatible return types
But the patch set is good enough as is to be just merged IMHO.
Thank you very much for the effort!
100 days until Python 2 end of life.