Changeset: 3c44907e0544 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3c44907e0544
Modified Files:
monetdb5/extras/pyapi/formatinput.c
monetdb5/extras/pyapi/pyapi.c
Branch: pyapi
Log Message:
Fix for code objects.
diffs (61 lines):
diff --git a/monetdb5/extras/pyapi/formatinput.c
b/monetdb5/extras/pyapi/formatinput.c
--- a/monetdb5/extras/pyapi/formatinput.c
+++ b/monetdb5/extras/pyapi/formatinput.c
@@ -10,6 +10,8 @@
#include "gdk.h"
#include "mal_exception.h"
+const size_t additional_argcount = 2;
+const char * additional_args[] = {"_columns", "_column_types"};
//! Parse a PyCodeObject from a string, the string is expected to be in the
format {@<encoded_function>};, where <encoded_function> is all the PyCodeObject
properties in order
PyObject *PyCodeObject_ParseString(char *string, char **msg);
@@ -251,8 +253,6 @@ char* FormatCode(char* code, char **args
bool multiline_statement = false;
int multiline_quotes = 0;
- size_t additional_argcount = 2;
- const char * additional_args[] = {"_columns", "_column_types"};
char base_start[] = "def pyfun(";
char base_end[] = "):\n";
*msg = NULL;
diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c
--- a/monetdb5/extras/pyapi/pyapi.c
+++ b/monetdb5/extras/pyapi/pyapi.c
@@ -734,7 +734,7 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st
// Now we will do the input handling (aka converting the input BATs to
numpy arrays)
// We will put the python arrays in a PyTuple object, we will use this
PyTuple object as the set of arguments to call the Python function
- pArgs = PyTuple_New(pci->argc - (pci->retc + 2) + 2);
+ pArgs = PyTuple_New(pci->argc - (pci->retc + 2) + (code_object == NULL ? 2
: 0));
pColumns = PyDict_New();
pColumnTypes = PyDict_New();
@@ -780,16 +780,19 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st
}
goto wrapup;
}
- arg_name = PyString_FromString(args[i]);
- arg_type = PyString_FromString(BatType_Format(pyinput_values[i -
(pci->retc + 2)].bat_type));
- PyDict_SetItem(pColumns, arg_name, result_array);
- PyDict_SetItem(pColumnTypes, arg_name, arg_type);
- Py_DECREF(arg_name); Py_DECREF(arg_type);
+ if (code_object == NULL) {
+ arg_name = PyString_FromString(args[i]);
+ arg_type = PyString_FromString(BatType_Format(pyinput_values[i -
(pci->retc + 2)].bat_type));
+ PyDict_SetItem(pColumns, arg_name, result_array);
+ PyDict_SetItem(pColumnTypes, arg_name, arg_type);
+ Py_DECREF(arg_name); Py_DECREF(arg_type);
+ }
PyTuple_SetItem(pArgs, ai++, result_array);
}
-
- PyTuple_SetItem(pArgs, ai++, pColumns);
- PyTuple_SetItem(pArgs, ai++, pColumnTypes);
+ if (code_object == NULL) {
+ PyTuple_SetItem(pArgs, ai++, pColumns);
+ PyTuple_SetItem(pArgs, ai++, pColumnTypes);
+ }
/*[EXECUTE_CODE]*/
VERBOSE_MESSAGE("Executing python code.\n");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list