[Python-checkins] cpython (merge 3.3 -> default): Merge issue #16218: Support non ascii characters in python launcher.
andrew.svetlov
python-checkins at python.org
Thu Nov 1 13:52:18 CET 2012
http://hg.python.org/cpython/rev/1267d64c14b3
changeset: 80156:1267d64c14b3
parent: 80154:5216c392239a
parent: 80155:02d25098ad57
user: Andrew Svetlov <andrew.svetlov at gmail.com>
date: Thu Nov 01 14:52:03 2012 +0200
summary:
Merge issue #16218: Support non ascii characters in python launcher.
Patch by Serhiy Storchaka.
files:
Lib/test/test_cmd_line_script.py | 9 +++++++++
Python/pythonrun.c | 9 +++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -363,6 +363,15 @@
self.assertTrue(text[1].startswith(' File '))
self.assertTrue(text[3].startswith('NameError'))
+ def test_non_utf8(self):
+ # Issue #16218
+ with temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir,
+ '\udcf1\udcea\udcf0\udce8\udcef\udcf2')
+ self._check_script(script_name, script_name, script_name,
+ script_dir, None,
+ importlib.machinery.SourceFileLoader)
+
def test_main():
support.run_unittest(CmdLineTest)
support.reap_children()
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1358,16 +1358,21 @@
{
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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list