--- a/src/PythonHandler.h Fri Dec 14 01:26:33 2018 +0100
+++ b/src/PythonHandler.h Fri Dec 14 02:03:24 2018 +0100
@@ -107,17 +107,17 @@
PyObject* pyModule;
PyObject* pyDict;
PyObject* pyWhere;
- PyObject* pyRecord = PyTuple_New(currentRecord.size());
+ PyObject* pyRecord = PyList_New(currentRecord.size());
//PyUnicode_FromWideChar()
for (int i = 0; i < currentRecord.size(); i++) {
- PyTuple_SetItem(pyRecord, i, PyUnicode_FromString(convertor.to_bytes(currentRecord[i]).c_str()));
+ PyList_SetItem(pyRecord, i, PyUnicode_FromString(convertor.to_bytes(currentRecord[i]).c_str()));
}
pyModule = PyImport_AddModule((char*) "__main__"); // FIXME: variable and Py_DecodeLocale ?
pyDict = PyModule_GetDict(pyModule);
- PyDict_SetItemString(pyDict, "record", pyRecord);
+ PyDict_SetItemString(pyDict, "r", pyRecord);
PyRun_SimpleString(convertor.to_bytes(pythonCode).c_str());
@@ -131,6 +131,14 @@
if (pyWhere) includeCurrentRecord = PyLong_AsLong(pyWhere);
+ if (includeCurrentRecord) {
+ for (int i = 0; i < currentRecord.size(); i++) {
+ Py_ssize_t l;
+ currentRecord[i] = wstring(PyUnicode_AsWideCharString(PyList_GetItem(pyRecord, i), &l));
+ }
+ }
+
+
if (includeCurrentRecord) for (string_t v : currentRecord) relationalWriter->writeAttribute(v);
includeCurrentRecord = true;
}