summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2000-07-03 09:57:53 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2000-07-03 09:57:53 (GMT)
commit891bc6548677fd0542fd715713f082be6f78e54e (patch)
treee0fe4c9b513d8068bb9521c1b118dea2f11784a9 /Objects/object.c
parent52dc76c81fffa709fae35af92538723d23ad18d6 (diff)
downloadcpython-891bc6548677fd0542fd715713f082be6f78e54e.zip
cpython-891bc6548677fd0542fd715713f082be6f78e54e.tar.gz
cpython-891bc6548677fd0542fd715713f082be6f78e54e.tar.bz2
If auto-conversion fails, the Unicode codecs will return NULL.
This is now checked and the error passed on to the caller.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 7f38dff..80a6e85 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -268,10 +268,11 @@ PyObject_Repr(v)
if (PyUnicode_Check(res)) {
PyObject* str;
str = PyUnicode_AsEncodedString(res, NULL, NULL);
- if (str) {
- Py_DECREF(res);
+ Py_DECREF(res);
+ if (str)
res = str;
- }
+ else
+ return NULL;
}
if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
@@ -310,14 +311,15 @@ PyObject_Str(v)
}
if (res == NULL)
return NULL;
- if (PyUnicode_Check(res)) {
- PyObject* str;
- str = PyUnicode_AsEncodedString(res, NULL, NULL);
- if (str) {
- Py_DECREF(res);
- res = str;
- }
- }
+ if (PyUnicode_Check(res)) {
+ PyObject* str;
+ str = PyUnicode_AsEncodedString(res, NULL, NULL);
+ Py_DECREF(res);
+ if (str)
+ res = str;
+ else
+ return NULL;
+ }
if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__str__ returned non-string (type %.200s)",