Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 80155:02d25098ad57 3.3
Issue #16218: Support non ascii characters in python launcher.
Patch by Serhiy Storchaka.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 01 Nov 2012 14:51:14 +0200 |
| parents | c3539eb02470 |
| children | 215297665098 |
comparison
equal
deleted
inserted
replaced
| 80153:23ebe277e982 | 80155:02d25098ad57 |
|---|---|
| 1356 int | 1356 int |
| 1357 static set_main_loader(PyObject *d, const char *filename, const char *loader_name) | 1357 static set_main_loader(PyObject *d, const char *filename, const char *loader_name) |
| 1358 { | 1358 { |
| 1359 PyInterpreterState *interp; | 1359 PyInterpreterState *interp; |
| 1360 PyThreadState *tstate; | 1360 PyThreadState *tstate; |
| 1361 PyObject *loader_type, *loader; | 1361 PyObject *filename_obj, *loader_type, *loader; |
| 1362 int result = 0; | 1362 int result = 0; |
| 1363 | |
| 1364 filename_obj = PyUnicode_DecodeFSDefault(filename); | |
| 1365 if (filename_obj == NULL) | |
| 1366 return -1; | |
| 1363 /* Get current thread state and interpreter pointer */ | 1367 /* Get current thread state and interpreter pointer */ |
| 1364 tstate = PyThreadState_GET(); | 1368 tstate = PyThreadState_GET(); |
| 1365 interp = tstate->interp; | 1369 interp = tstate->interp; |
| 1366 loader_type = PyObject_GetAttrString(interp->importlib, loader_name); | 1370 loader_type = PyObject_GetAttrString(interp->importlib, loader_name); |
| 1367 if (loader_type == NULL) { | 1371 if (loader_type == NULL) { |
| 1372 Py_DECREF(filename_obj); | |
| 1368 return -1; | 1373 return -1; |
| 1369 } | 1374 } |
| 1370 loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename); | 1375 loader = PyObject_CallFunction(loader_type, "sN", "__main__", filename_obj); |
| 1371 Py_DECREF(loader_type); | 1376 Py_DECREF(loader_type); |
| 1372 if (loader == NULL) { | 1377 if (loader == NULL) { |
| 1373 return -1; | 1378 return -1; |
| 1374 } | 1379 } |
| 1375 if (PyDict_SetItemString(d, "__loader__", loader) < 0) { | 1380 if (PyDict_SetItemString(d, "__loader__", loader) < 0) { |
