port some Python wrapper code fixes from C++ jsonnet

See commits on the C++ repo:

- 913281d203
- 842d31eefd
This commit is contained in:
John Bartholomew 2025-01-20 20:56:51 +00:00
parent e1304d1698
commit 9e1e952016

View File

@ -186,7 +186,7 @@ static struct JsonnetJsonValue *cpython_native_callback(
}
// Call python function.
result = PyEval_CallObject(ctx->callback, arglist);
result = PyObject_CallObject(ctx->callback, arglist);
Py_DECREF(arglist);
if (result == NULL) {
@ -226,7 +226,7 @@ static int cpython_import_callback(void *ctx_, const char *base, const char *rel
PyEval_RestoreThread(*ctx->py_thread);
arglist = Py_BuildValue("(s, s)", base, rel);
result = PyEval_CallObject(ctx->callback, arglist);
result = PyObject_CallObject(ctx->callback, arglist);
Py_DECREF(arglist);
if (result == NULL) {
@ -255,7 +255,7 @@ static int cpython_import_callback(void *ctx_, const char *base, const char *rel
success = 0;
} else {
char *content_buf;
ssize_t content_len;
Py_ssize_t content_len;
#if PY_MAJOR_VERSION >= 3
const char *found_here_cstr = PyUnicode_AsUTF8(file_name);
#else