Re: Is there conversion method to convert pyunicodeobject to pybyteobject?
Got it worked with the following change. PyUnicodeObject *p = ...whatever...; char* tmp = (char *)p; PyObject* arg = PyBytes_FromString (tmp); function( (PyBytesObject*) arg); From : MathanKlt;switch2mat...@gmail.comgt; To : python-list lt;python-list@python.orggt; Date : Sat, 15 May 2010 02:50:22 -1200 Subject : Is there conversion method to convert pyunicodeobject to pybyteobject? Hi All, A variable whose data type is PyUnicodeObject is to be assigned to varioable of PyBytesObject type example : void function( (PyBytesObject* byte){} PyUnicodeObject *p = ...whatever...; function( (PyBytesObject*)p); compiled and got a Bus Error. Cheers, Mathan -- http://mail.python.org/mailman/listinfo/python-list
Is there conversion method to convert pyunicodeobject to pybyteobject?
Hi All, A variable whose data type is PyUnicodeObject is to be assigned to varioable of PyBytesObject type example : PyUnicodeObject *p = ...whatever...; function( (PyByteObject*p)); compiled and got a Bus Error. Cheers, Mathan -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there conversion method to convert pyunicodeobject to pybyteobject?
On 5/15/2010 10:50 AM, MathanK wrote: This is the third time, at least, that you posted this, though the first time you asked a question. You have given no indication that you bothered to look in the manual before or between postings. A variable whose data type is PyUnicodeObject is to be assigned to varioable of PyBytesObject type example : PyUnicodeObject *p = ...whatever...; function( (PyByteObject*p)); C casting is usually not conversion. It says pretend that the data is another type, even though it is not. Only use it when you actually know what you are doing. compiled and got a Bus Error. In Python, b = p.encode('utf-8') or whatever encoding you want. Look in the C-API manual for the CPython function that actually does this. -- http://mail.python.org/mailman/listinfo/python-list