From 90c0eb28c5ff1da76b258f9cf6a54abc6df19675 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 1 Nov 2012 14:51:14 +0200 Subject: Issue #16218: Support non ascii characters in python launcher. Patch by Serhiy Storchaka. --- Python/pythonrun.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index b1ca125781..7c4fb4a3c9 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1358,16 +1358,21 @@ static set_main_loader(PyObject *d, const char *filename, const char *loader_nam { PyInterpreterState *interp; PyThreadState *tstate; - PyObject *loader_type, *loader; + PyObject *filename_obj, *loader_type, *loader; int result = 0; + + filename_obj = PyUnicode_DecodeFSDefault(filename); + if (filename_obj == NULL) + return -1; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp; loader_type = PyObject_GetAttrString(interp->importlib, loader_name); if (loader_type == NULL) { + Py_DECREF(filename_obj); return -1; } - loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename); + loader = PyObject_CallFunction(loader_type, "sN", "__main__", filename_obj); Py_DECREF(loader_type); if (loader == NULL) { return -1; -- cgit v1.2.1