Author: guido.van.rossum
Date: Thu Aug  9 22:47:59 2007
New Revision: 56873

Modified:
   python/branches/py3k/Objects/object.c
Log:
Oops.  The PyObject_Print() function was totally broken; the original code
was relying on PyString.tp_print but that no longer works.
Fortunately it's rarely called; only the gdb 'pyo' command seems affected.


Modified: python/branches/py3k/Objects/object.c
==============================================================================
--- python/branches/py3k/Objects/object.c       (original)
+++ python/branches/py3k/Objects/object.c       Thu Aug  9 22:47:59 2007
@@ -284,12 +284,28 @@
                        if (flags & Py_PRINT_RAW)
                                s = PyObject_Str(op);
                        else
-                               s = PyObject_ReprStr8(op);
+                               s = PyObject_Repr(op);
                        if (s == NULL)
                                ret = -1;
+                        else if (PyString_Check(s)) {
+                               fwrite(PyString_AS_STRING(s), 1,
+                                      PyString_GET_SIZE(s), fp);
+                       }
+                       else if (PyUnicode_Check(s)) {
+                               PyObject *t;
+                               t = _PyUnicode_AsDefaultEncodedString(s, NULL);
+                               if (t == NULL)
+                                       ret = 0;
+                               else {
+                                       fwrite(PyString_AS_STRING(t), 1,
+                                              PyString_GET_SIZE(t), fp);
+                               }
+                       }
                        else {
-                               ret = internal_print(s, fp, Py_PRINT_RAW,
-                                                    nesting+1);
+                               PyErr_Format(PyExc_TypeError,
+                                            "str() or repr() returned 
'%.100s'",
+                                            s->ob_type->tp_name);
+                               ret = -1;
                        }
                        Py_XDECREF(s);
                }
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to