[Python-checkins] r46346 - python/branches/sreifschneider-newnewexcept/Objects/exceptions.c

richard.jones python-checkins at python.org
Fri May 26 17:51:52 CEST 2006


Author: richard.jones
Date: Fri May 26 17:51:51 2006
New Revision: 46346

Modified:
   python/branches/sreifschneider-newnewexcept/Objects/exceptions.c
Log:
better unicode representation

Modified: python/branches/sreifschneider-newnewexcept/Objects/exceptions.c
==============================================================================
--- python/branches/sreifschneider-newnewexcept/Objects/exceptions.c	(original)
+++ python/branches/sreifschneider-newnewexcept/Objects/exceptions.c	Fri May 26 17:51:51 2006
@@ -150,6 +150,18 @@
 static PyObject *
 BaseException_unicode(BaseExceptionObject *self)
 {
+    if (PySequence_Length(self->args) == 0)
+        return PyUnicode_FromUnicode(NULL, 0);
+    if (PySequence_Length(self->args) == 1) {
+        PyObject *temp = PySequence_GetItem(self->args, 0);
+        PyObject *unicode_obj;
+        if (!temp) {
+            return NULL;
+        }
+        unicode_obj = PyObject_Unicode(temp);
+        Py_DECREF(temp);
+        return unicode_obj;
+    }
     return PyObject_Unicode(self->args);
 }
 #endif /* Py_USING_UNICODE */


More information about the Python-checkins mailing list