Is there conversion method to convert pyunicodeobject to pybyteobject?

MathanK switch2mathan at gmail.com
Wed May 19 02:57:40 EDT 2010


Got it worked with the following change.

PyUnicodeObject *p = ...whatever...;

char* tmp = (char *)p;
PyObject* arg = PyBytes_FromString (tmp); 

function( (PyBytesObject*) arg); 


>From : MathanK<switch2mathan at gmail.com>
To : "python-list" <python-list at python.org>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100518/3ecf3575/attachment-0001.html>


More information about the Python-list mailing list