Index ¦ Archives  ¦ Atom  ¦ RSS

Fixing python-purple for newer Cython versions

I did another incursion into plugins for Pidgin recently and found a great project called python-purple (not for plugins). However, it was made almost 2 years ago and Cython's handling of 'x and y' changed to match Python's semantics instead of C's. This means 'x and y' returns either x or y and doesn't cast either to a boolean. There are a bunch of reasons why this is good/bad but Python's way is what Cython is supposed to implement so they did.

Many people have since tried to compile python-purple since Cython 0.12 and have come across this issue, but nobody has since explained the problem and solution. So here it is, the problem:

In 3 locations, account.pyx and purple.pyx use the 'x and y' semantic but x and y are not the same type so it tries to convert them to Python objects. Since no Python object wrapper has been created for the likes of PurplePluginInfo and the such, it fails at doing so. What must be done is to convert 'x and y' to 'bint (x) and bint(y)'.

Another problem with the existing code is that Cython converts "quit" and "quit\n" to conflicting C variables. I'm not sure how to fix this the best way, so I just went through all the conflicting strings and removed the \n at the end to fix that. Since it was only in debugging output, it won't actually change the behavior of the code.

I've published this to github, but while writing this I found some python bindings that work in Windows. I haven't gotten Cython to work on Windows so I don't know if python-purple works there but I know it works on Linux. If anybody tries python-purple out on Windows, let me know in the comments!

© Fahrzin Hemmati. Built using Pelican. Theme by Giulio Fidente on github.