On Sun, 18 Nov 2012 16:36:14 +0100, Luca Beltrame <ei...@heavensinferno.net> wrote: > Hello, > > while testing PyKDE4's modules with Python3, I noticed that the i18n() > calls, > which accept const char*, are not properly handled in Python 3 (both with > API > version 1 and 2): > > In [2]: from PyKDE4.kdecore import i18n > > In [3]: i18n("Test") > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-3-00970cb5d435> in <module>() > ----> 1 i18n("Test") > > TypeError: i18n(): argument 1 has unexpected type 'str' > > It does work if I pass bytes, but that's not correct, as we're dealing > with > strings here. > > PyQt documentation states that char* or const char* would be acceptable > with > strings (Python 3 strings). > > As the original SIP file had custom code inside, I'm attaching it here. I > looked at it briefly, but I couldn't find why it didn't work. > > Can anyone shed a light on this issue?
You don't specify an encoding to be used when converting char* to a string object. It will default to that defined by %DefaultEncoding. For Python3 PyQt sets this to ASCII, so either PyKDE is using %DefaultEncoding to change the default, or its passing "-x Py_v3" to sip which will set defaults for Python2 rather than Python3. Note that there is a sip bug in generating the Python3 docstring for unencoded char* where it generates "str" rather than "bytes". Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt