From: Victor Stinner Date: Fri, 7 May 2010 00:41:18 +0000 (+0000) Subject: code_repr(): use %U to format the filename X-Git-Tag: v3.2a1~895 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3c7381c39f02a29538ba0dc2f5731aee73ceb1a;p=thirdparty%2FPython%2Fcpython.git code_repr(): use %U to format the filename Avoid useless unicode decoding/recoding of the filename. --- diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 3e71e4cde3d7..ad2068bb2a87 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -340,16 +340,20 @@ code_dealloc(PyCodeObject *co) static PyObject * code_repr(PyCodeObject *co) { - int lineno = -1; - char *filename = "???"; - + int lineno; if (co->co_firstlineno != 0) lineno = co->co_firstlineno; - if (co->co_filename && PyUnicode_Check(co->co_filename)) - filename = _PyUnicode_AsString(co->co_filename); - return PyUnicode_FromFormat( - "", - co->co_name, co, filename, lineno); + else + lineno = -1; + if (co->co_filename && PyUnicode_Check(co->co_filename)) { + return PyUnicode_FromFormat( + "", + co->co_name, co, co->co_filename, lineno); + } else { + return PyUnicode_FromFormat( + "", + co->co_name, co, lineno); + } } static PyObject *