kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit c3ab570f56a0a6d9810e3d2caf7053f7a4093ddc
parent 31b6365da39bfc676df9d936219b3e95ea2ec711
Author: Joris Vink <joris@coders.se>
Date:   Sat, 16 Mar 2019 16:13:52 +0100

Append full module path if it is a directory.

Diffstat:
src/python.c | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/python.c b/src/python.c @@ -17,6 +17,7 @@ #include <sys/param.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/socket.h> #include <sys/wait.h> #include <sys/un.h> @@ -1369,9 +1370,16 @@ python_kore_proc(PyObject *self, PyObject *args) static PyObject * python_import(const char *path) { + struct stat st; PyObject *module; char *dir, *file, *copy, *p; + if (stat(path, &st) == -1) + fatal("python_import: stat(%s): %s", path, errno_s); + + if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode)) + fatal("python_import: '%s' is not a file or directory", path); + copy = kore_strdup(path); if ((file = basename(copy)) == NULL) @@ -1383,6 +1391,10 @@ python_import(const char *path) *p = '\0'; python_append_path(dir); + + if (S_ISDIR(st.st_mode)) + python_append_path(path); + module = PyImport_ImportModule(file); if (module == NULL) PyErr_Print();