py3: Base: files I-R ported to python3
PyObjectBase.cpp and PyObjectBase.h not included issue 0000995
This commit is contained in:
@@ -149,7 +149,7 @@ PP_Debug_Function(PyObject *func, PyObject *args)
|
||||
/* expand tuple at front */
|
||||
// it seems that some versions of python want just 2 arguments; in that
|
||||
// case, remove trailing 1
|
||||
#if (PY_MAJOR_VERSION==2)&&(PY_MINOR_VERSION>=2)
|
||||
#if (PY_MAJOR_VERSION>=2)&&(PY_MINOR_VERSION>=2)
|
||||
oops = _PyTuple_Resize(&args, (1 + PyTuple_Size(args)));
|
||||
#else
|
||||
oops = _PyTuple_Resize(&args, (1 + PyTuple_Size(args)),1);
|
||||
@@ -241,9 +241,15 @@ void PP_Fetch_Error_Text()
|
||||
pystring = NULL;
|
||||
if (errobj != NULL &&
|
||||
(pystring = PyObject_Str(errobj)) != NULL && /* str(errobj) */
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
(PyUnicode_Check(pystring)) ) /* str() increfs */
|
||||
{
|
||||
strncpy(PP_last_error_type, PyUnicode_AsUTF8(pystring), MAX); /*Py->C*/
|
||||
#else
|
||||
(PyString_Check(pystring)) ) /* str() increfs */
|
||||
{
|
||||
strncpy(PP_last_error_type, PyString_AsString(pystring), MAX); /*Py->C*/
|
||||
#endif
|
||||
PP_last_error_type[MAX-1] = '\0';
|
||||
}
|
||||
else
|
||||
@@ -264,7 +270,11 @@ void PP_Fetch_Error_Text()
|
||||
PyObject* value = PyDict_GetItemString(errdata,"swhat");
|
||||
|
||||
if (value!=NULL) {
|
||||
strncpy(PP_last_error_info, PyString_AsString(value), MAX);
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
strncpy(PP_last_error_info, PyString_AsString(pystring), MAX);
|
||||
#else
|
||||
strncpy(PP_last_error_info, PyUnicode_AsUTF8(pystring), MAX);
|
||||
#endif
|
||||
PP_last_error_info[MAX-1] = '\0';
|
||||
}
|
||||
|
||||
@@ -273,9 +283,15 @@ void PP_Fetch_Error_Text()
|
||||
}
|
||||
else if (errdata != NULL &&
|
||||
(pystring = PyObject_Str(errdata)) != NULL && /* str(): increfs */
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
(PyUnicode_Check(pystring)) )
|
||||
{
|
||||
strncpy(PP_last_error_info, PyUnicode_AsUTF8(pystring), MAX); /*Py->C*/
|
||||
#else
|
||||
(PyString_Check(pystring)) )
|
||||
{
|
||||
strncpy(PP_last_error_info, PyString_AsString(pystring), MAX); /*Py->C*/
|
||||
#endif
|
||||
PP_last_error_info[MAX-1] = '\0';
|
||||
}
|
||||
else
|
||||
@@ -289,7 +305,12 @@ void PP_Fetch_Error_Text()
|
||||
|
||||
pystring = NULL;
|
||||
if (errtraceback != NULL &&
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
(PP_Run_Function("StringIO", "StringIO", "O", &pystring, "()") == 0) &&
|
||||
#else
|
||||
(PP_Run_Function("io", "StringIO", "O", &pystring, "()") == 0) &&
|
||||
#endif
|
||||
|
||||
(PyTraceBack_Print(errtraceback, pystring) == 0) &&
|
||||
(PP_Run_Method(pystring, "getvalue", "s", &tempstr, "()") == 0) )
|
||||
{
|
||||
@@ -581,7 +602,11 @@ PP_Run_Bytecode(PyObject *codeobj, /* run compiled bytecode object */
|
||||
if (PP_DEBUG)
|
||||
presult = PP_Debug_Bytecode(codeobj, dict); /* run in pdb */
|
||||
else
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
presult = PyEval_EvalCode((PyObject*)codeobj, dict, dict);
|
||||
#else
|
||||
presult = PyEval_EvalCode((PyCodeObject *)codeobj, dict, dict);
|
||||
#endif
|
||||
return PP_Convert_Result(presult, resfmt, restarget); /* expr val to C */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user