diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 17:15:42 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-21 17:15:42 (GMT) |
commit | 6ced7c433353208e5b9d4dc25018937f1c9ae87d (patch) | |
tree | 61efdd2c527ab2eeeff1dd306218b91efbe1b91d /Modules/readline.c | |
parent | 44afe2b35a3f82f26d35a2cec507ec6d59e6d6d3 (diff) | |
download | cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.zip cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.tar.gz cpython-6ced7c433353208e5b9d4dc25018937f1c9ae87d.tar.bz2 |
Issue #10833: Use PyErr_Format() and PyUnicode_FromFormat() instead of
PyOS_snprintf() to avoid temporary buffer allocated on the stack and a
conversion from bytes to Unicode.
Diffstat (limited to 'Modules/readline.c')
-rw-r--r-- | Modules/readline.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Modules/readline.c b/Modules/readline.c index 8337956..a5e48ab 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -233,10 +233,9 @@ set_hook(const char *funcname, PyObject **hook_var, PyObject *args) Py_XDECREF(tmp); } else { - PyOS_snprintf(buf, sizeof(buf), - "set_%.50s(func): argument not callable", - funcname); - PyErr_SetString(PyExc_TypeError, buf); + PyErr_Format(PyExc_TypeError, + "set_%.50s(func): argument not callable", + funcname); return NULL; } Py_RETURN_NONE; @@ -890,7 +889,7 @@ setup_readline(void) #endif #ifdef __APPLE__ - /* the libedit readline emulation resets key bindings etc + /* the libedit readline emulation resets key bindings etc * when calling rl_initialize. So call it upfront */ if (using_libedit_emulation) @@ -930,11 +929,11 @@ setup_readline(void) */ #ifdef __APPLE__ if (using_libedit_emulation) - rl_read_init_file(NULL); + rl_read_init_file(NULL); else #endif /* __APPLE__ */ rl_initialize(); - + RESTORE_LOCALE(saved_locale) } |