App: remove Py2 code from several src/App .cpp files

This commit is contained in:
luz paz
2021-04-14 10:18:27 -04:00
committed by wwmayer
parent 80415446cf
commit a1fc733ddf
12 changed files with 0 additions and 268 deletions

View File

@@ -253,7 +253,6 @@ PyObject *PropertyFileIncluded::getPyObject(void)
return p;
}
#if PY_MAJOR_VERSION >= 3
namespace App {
const char* getNameFromFile(PyObject* value)
{
@@ -286,11 +285,9 @@ bool isIOFile(PyObject* file)
return isFile;
}
}
#endif
void PropertyFileIncluded::setPyObject(PyObject *value)
{
#if PY_MAJOR_VERSION >= 3
std::string string;
if (PyUnicode_Check(value)) {
string = PyUnicode_AsUTF8(value);
@@ -301,21 +298,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value)
else if (isIOFile(value)){
string = getNameFromFile(value);
}
#else
std::string string;
if (PyUnicode_Check(value)) {
PyObject* unicode = PyUnicode_AsUTF8String(value);
string = PyString_AsString(unicode);
Py_DECREF(unicode);
}
else if (PyString_Check(value)) {
string = PyString_AsString(value);
}
else if (PyFile_Check(value)) {
PyObject* FileName = PyFile_Name(value);
string = PyString_AsString(FileName);
}
#endif
else if (PyTuple_Check(value)) {
if (PyTuple_Size(value) != 2)
throw Base::TypeError("Tuple needs size of (filePath,newFileName)");
@@ -324,7 +306,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value)
// decoding file
std::string fileStr;
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(file)) {
fileStr = PyUnicode_AsUTF8(file);
}
@@ -334,20 +315,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value)
else if (isIOFile(value)) {
fileStr = getNameFromFile(file);
}
#else
if (PyUnicode_Check(file)) {
PyObject* unicode = PyUnicode_AsUTF8String(file);
fileStr = PyString_AsString(unicode);
Py_DECREF(unicode);
}
else if (PyString_Check(file)) {
fileStr = PyString_AsString(file);
}
else if (PyFile_Check(file)) {
PyObject* FileName = PyFile_Name(file);
fileStr = PyString_AsString(FileName);
}
#endif
else {
std::string error = std::string("First item in tuple must be a file or string, not ");
error += file->ob_type->tp_name;
@@ -356,7 +323,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value)
// decoding name
std::string nameStr;
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(name)) {
nameStr = PyUnicode_AsUTF8(name);
}
@@ -366,15 +332,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value)
else if (isIOFile(value)) {
nameStr = getNameFromFile(name);
}
#else
if (PyString_Check(name)) {
nameStr = PyString_AsString(name);
}
else if (PyFile_Check(name)) {
PyObject* FileName = PyFile_Name(name);
nameStr = PyString_AsString(FileName);
}
#endif
else {
std::string error = std::string("Second item in tuple must be a string, not ");
error += name->ob_type->tp_name;