From: Terry Reedy on
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.