py3: Gui: files A-P ported to python3

This commit is contained in:
Yorik van Havre
2017-05-05 19:33:03 +02:00
committed by wmayer
parent 3299c363ab
commit 7e39fed862
10 changed files with 274 additions and 25 deletions

View File

@@ -437,7 +437,11 @@ void PythonDebugger::runFile(const QString& fn)
dict = PyModule_GetDict(module);
dict = PyDict_Copy(dict);
if (PyDict_GetItemString(dict, "__file__") == NULL) {
#if PY_MAJOR_VERSION >= 3
PyObject *f = PyUnicode_FromString((const char*)pxFileName);
#else
PyObject *f = PyString_FromString((const char*)pxFileName);
#endif
if (f == NULL) {
fclose(fp);
return;
@@ -576,7 +580,11 @@ int PythonDebugger::tracer_callback(PyObject *obj, PyFrameObject *frame, int wha
//no = frame->f_tstate->recursion_depth;
//std::string funcname = PyString_AsString(frame->f_code->co_name);
#if PY_MAJOR_VERSION >= 3
QString file = QString::fromUtf8(PyUnicode_AsUTF8(frame->f_code->co_filename));
#else
QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename));
#endif
switch (what) {
case PyTrace_CALL:
self->depth++;