Message1934
This one actually fails on CPython 2.2 though
CPython > 2.2 calls PyObject_Str on anything printed. Jython doesn't have an equivalent function; in this case it just calls __str__ (in StdoutWrapper) on any object printed.
PyObject_Str looks like it's a safer version of __str__ for situations like these, it specially handles unicode objects, returning PyUnicode_AsEncodedString (which is like our encode_UnicodeEscape)
We could special case unicode objects in StdoutWrapper, but I see PythonObject_Str used in a few places in CPython. So patching StdoutWrapper might miss other cases where this is a problem
$ grep -r PyObject_Str\( * | grep \.c:
Modules/_csv.c: str = PyObject_Str(field);
Modules/_tkinter.c: PyObject *v = PyObject_Str(value);
Modules/_tkinter.c: PyObject *v = PyObject_Str(value);
Objects/descrobject.c: return PyObject_Str(pp->dict);
Objects/fileobject.c: value = PyObject_Str(v);
Objects/object.c: s = PyObject_Str(op);
Objects/object.c:PyObject_Str(PyObject *v)
Objects/stringobject.c: op = (PyStringObject *) PyObject_Str((PyObject *)op);
Objects/stringobject.c: return PyObject_Str(x);
Objects/stringobject.c: temp = PyObject_Str(v);
Objects/stringobject.c: PyObject_Str() assure this */
Objects/unicodeobject.c: temp = PyObject_Str(v);
Objects/unicodeobject.c: PyObject_Repr() and PyObject_Str() assure
Python/bltinmodule.c: po = PyObject_Str(v);
Python/codecs.c: PyObject *string = PyObject_Str(name);
Python/errors.c: tmp = PyObject_Str(v);
Python/exceptions.c: out = PyObject_Str(tmp);
Python/exceptions.c: out = PyObject_Str(args);
Python/exceptions.c: str = PyObject_Str(msg);
Python/pythonrun.c: v = PyObject_Str(v);
Python/pythonrun.c: w = PyObject_Str(w);
Python/pythonrun.c: PyObject *s = PyObject_Str(value); |
|
Date |
User |
Action |
Args |
2008-02-20 17:18:03 | admin | link | issue1802339 messages |
2008-02-20 17:18:03 | admin | create | |
|