SFML community forums

Bindings - other languages => Python => Topic started by: lattyware on July 22, 2011, 11:42:00 pm

Title: PySFML2 Cython Text under Python 3
Post by: lattyware on July 22, 2011, 11:42:00 pm
I'm running PySFML2-Cython under Python 3, appears to work alright, I'm poriting across a project that was using the old library, and the Text class that replaces the old String class is causing trouble.

I try and pass it a python3 str (unicode) and I get this error:

self.text = sf.Text(value)

  File "sf.pyx", line 1591, in sf.Text.__cinit__ (sf.cpp:17293)
TypeError: expected bytes, str found

I was under the impression that the Text class should have supported unicode, unlike everything else, but I tried it the other way, encoding it to bytes:

self.text = sf.Text(bytes(value, "UTF-8"))

  File "sf.pyx", line 1614, in sf.Text.__cinit__ (sf.cpp:17503)
TypeError: Expected str or unicode for string, got <class 'bytes'>

Is this something stupid I'm missing, or a problem with the bindings?
Title: PySFML2 Cython Text under Python 3
Post by: bastien on July 23, 2011, 11:01:44 am
Thanks, it should work now.
Title: PySFML2 Cython Text under Python 3
Post by: lattyware on July 23, 2011, 03:59:19 pm
Quote from: "bastien"
Thanks, it should work now.


Cheers for the quick fix!

The new bindings are a lot better, I can get rid of a lot of old code I had that was simply wrapping the old methods and stuff to make them more pythonic. It looks like it'll make the game a lot easier to work with in the long run.