summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-04 00:41:39 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-04 00:41:39 (GMT)
commitf15a29f975bbdef6de0aa19a19b176d1baf8f5ab (patch)
tree60f4f72289129eaa808e05f2b7c7fb7bde077371 /Objects/object.c
parentbae5cedb8d41edc20bea54b8bff0c7f835de8043 (diff)
downloadcpython-f15a29f975bbdef6de0aa19a19b176d1baf8f5ab.zip
cpython-f15a29f975bbdef6de0aa19a19b176d1baf8f5ab.tar.gz
cpython-f15a29f975bbdef6de0aa19a19b176d1baf8f5ab.tar.bz2
More coding by random modification.
Encoding now return bytes instead of str8. eval(), exec(), compile() now accept unicode or bytes.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/object.c b/Objects/object.c
index ada1d1e..81f5669 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -422,7 +422,8 @@ PyObject_Str(PyObject *v)
return NULL;
if (PyUnicode_Check(res)) {
PyObject* str;
- str = PyUnicode_AsEncodedString(res, NULL, NULL);
+ str = _PyUnicode_AsDefaultEncodedString(res, NULL);
+ Py_XINCREF(str);
Py_DECREF(res);
if (str)
res = str;
@@ -929,12 +930,12 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
PyTypeObject *tp = v->ob_type;
int err;
- if (!PyString_Check(name)){
+ if (!PyString_Check(name)) {
/* The Unicode to string conversion is done here because the
existing tp_setattro slots expect a string object as name
and we wouldn't want to break those. */
if (PyUnicode_Check(name)) {
- name = PyUnicode_AsEncodedString(name, NULL, NULL);
+ name = _PyUnicode_AsDefaultEncodedString(name, NULL);
if (name == NULL)
return -1;
}
@@ -946,8 +947,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
return -1;
}
}
- else
- Py_INCREF(name);
+ Py_INCREF(name);
PyString_InternInPlace(&name);
if (tp->tp_setattro != NULL) {
@@ -961,6 +961,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
return err;
}
Py_DECREF(name);
+ assert(name->ob_refcnt >= 1);
if (tp->tp_getattr == NULL && tp->tp_getattro == NULL)
PyErr_Format(PyExc_TypeError,
"'%.100s' object has no attributes "