I'm trying to emulate code.InteractiveInterpreter from the embedded Python C API. I'm using PyEval_Evalcode to evaluate the user input. I am trying to evaluate user input in the interpreter and return the output as a string (just like the interpreter would). However, PyEval_Evalcode returns a multitude of datatypes wrapped in PyObject*.  Is there any way to do what I am trying to do? 
Constraints: It needs to be done using the embedding api. Cannot be done using PyRun_RunSimpleString() and laying down a code.InteractiveInterpreter.
I have binary string and cannot return it as string because of null terminated string.
if(PyString_Check(pValue))
                {
                    const char* s=/*PyBytes_AsString*/PyString_AsString(PyObject_Repr(pValue)); //return hex representation in ascii
                    int sz=PyString_Size(pValue);//size is valid
                    const char* s= PyString_AsString(pValue);//return only  below null terminated string
                }
Evaluating Python Code From the CAPI and getting Output