diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-17 09:35:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-17 09:35:44 (GMT) |
commit | 2e71d014ea9e22c846b459e6420e5ef2c726ac76 (patch) | |
tree | 3f09e1f22aecb3885ef7c00f7f07cb81860bc13a /Modules/main.c | |
parent | 67635145038f747bb70aa2fd2321a6fd6eecbb1a (diff) | |
download | cpython-2e71d014ea9e22c846b459e6420e5ef2c726ac76.zip cpython-2e71d014ea9e22c846b459e6420e5ef2c726ac76.tar.gz cpython-2e71d014ea9e22c846b459e6420e5ef2c726ac76.tar.bz2 |
Merged revisions 81250-81253 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r81250 | victor.stinner | 2010-05-17 03:13:37 +0200 (lun., 17 mai 2010) | 2 lines
Issue #6697: Fix a crash if code of "python -c code" contains surrogates
........
r81251 | victor.stinner | 2010-05-17 03:26:01 +0200 (lun., 17 mai 2010) | 3 lines
PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead
of strict) error handler to escape surrogates
........
r81252 | victor.stinner | 2010-05-17 10:58:51 +0200 (lun., 17 mai 2010) | 6 lines
handle_system_exit() flushs files to warranty the output order
PyObject_Print() writes into the C object stderr, whereas PySys_WriteStderr()
writes into the Python object sys.stderr. Each object has its own buffer, so
call sys.stderr.flush() and fflush(stderr).
........
r81253 | victor.stinner | 2010-05-17 11:33:42 +0200 (lun., 17 mai 2010) | 6 lines
Fix refleak in internal_print() introduced by myself in r81251
_PyUnicode_AsDefaultEncodedString() uses a magical PyUnicode attribute to
automatically destroy PyUnicode_EncodeUTF8() result when the unicode string is
destroyed.
........
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/main.c b/Modules/main.c index eb44aa9..4dcc32d 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -516,18 +516,22 @@ Py_Main(int argc, wchar_t **argv) } if (command) { + char *commandStr; PyObject *commandObj = PyUnicode_FromWideChar( command, wcslen(command)); free(command); - if (commandObj != NULL) { - sts = PyRun_SimpleStringFlags( - _PyUnicode_AsString(commandObj), &cf) != 0; + if (commandObj != NULL) + commandStr = _PyUnicode_AsString(commandObj); + else + commandStr = NULL; + if (commandStr != NULL) { + sts = PyRun_SimpleStringFlags(commandStr, &cf) != 0; + Py_DECREF(commandObj); } else { PyErr_Print(); sts = 1; } - Py_DECREF(commandObj); } else if (module) { sts = RunModule(module, 1); } |