diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-07-21 17:22:18 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-07-21 17:22:18 (GMT) |
commit | 9f2e346911988cda95fec7c901e8d10d34fa9563 (patch) | |
tree | 1632c78fb8e18b2f789102451bedd15996bff6c5 /Objects/unicodeobject.c | |
parent | b972a78e17beeb997d809d87f2e422e6622efd52 (diff) | |
download | cpython-9f2e346911988cda95fec7c901e8d10d34fa9563.zip cpython-9f2e346911988cda95fec7c901e8d10d34fa9563.tar.gz cpython-9f2e346911988cda95fec7c901e8d10d34fa9563.tar.bz2 |
Merged revisions 56467-56482 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines
Merged revisions 56466-56476 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
........
................
r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines
PEP 3123: Use proper C inheritance for PyObject.
................
r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines
Add longintrepr.h to Python.h, so that the compiler can
see that PyFalse is really some kind of PyObject*.
................
r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines
Qualify SHIFT, MASK, BASE.
................
r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines
Correctly refer to _ob_next.
................
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1399d19..bf031bb 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -338,7 +338,7 @@ void unicode_dealloc(register PyUnicodeObject *unicode) else { PyMem_DEL(unicode->str); Py_XDECREF(unicode->defenc); - unicode->ob_type->tp_free((PyObject *)unicode); + Py_Type(unicode)->tp_free((PyObject *)unicode); } } @@ -352,7 +352,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) return -1; } v = (PyUnicodeObject *)*unicode; - if (v == NULL || !PyUnicode_Check(v) || v->ob_refcnt != 1 || length < 0) { + if (v == NULL || !PyUnicode_Check(v) || Py_Refcnt(v) != 1 || length < 0) { PyErr_BadInternalCall(); return -1; } @@ -1004,7 +1004,7 @@ PyObject *PyUnicode_FromEncodedObject(register PyObject *obj, PyErr_Format(PyExc_TypeError, "coercing to Unicode: need string or buffer, " "%.80s found", - obj->ob_type->tp_name); + Py_Type(obj)->tp_name); goto onError; } @@ -1054,7 +1054,7 @@ PyObject *PyUnicode_Decode(const char *s, if (!PyUnicode_Check(unicode)) { PyErr_Format(PyExc_TypeError, "decoder did not return an unicode object (type=%.400s)", - unicode->ob_type->tp_name); + Py_Type(unicode)->tp_name); Py_DECREF(unicode); goto onError; } @@ -3722,8 +3722,7 @@ encoding_map_dealloc(PyObject* o) } static PyTypeObject EncodingMapType = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "EncodingMap", /*tp_name*/ sizeof(struct encoding_map), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -3984,7 +3983,7 @@ charmapencode_result charmapencode_output(Py_UNICODE c, PyObject *mapping, char *outstart; Py_ssize_t outsize = PyBytes_GET_SIZE(outobj); - if (mapping->ob_type == &EncodingMapType) { + if (Py_Type(mapping) == &EncodingMapType) { int res = encoding_map_lookup(c, mapping); Py_ssize_t requiredsize = *outpos+1; if (res == -1) @@ -4056,7 +4055,7 @@ int charmap_encoding_error( /* find all unencodable characters */ while (collendpos < size) { PyObject *rep; - if (mapping->ob_type == &EncodingMapType) { + if (Py_Type(mapping) == &EncodingMapType) { int res = encoding_map_lookup(p[collendpos], mapping); if (res != -1) break; @@ -5114,7 +5113,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq) PyErr_Format(PyExc_TypeError, "sequence item %zd: expected string or Unicode," " %.80s found", - i, item->ob_type->tp_name); + i, Py_Type(item)->tp_name); goto onError; } item = PyUnicode_FromObject(item); @@ -6155,7 +6154,7 @@ unicode_encode(PyUnicodeObject *self, PyObject *args) PyErr_Format(PyExc_TypeError, "encoder did not return a bytes object " "(type=%.400s)", - v->ob_type->tp_name); + Py_Type(v)->tp_name); Py_DECREF(v); return NULL; } @@ -6191,7 +6190,7 @@ unicode_decode(PyUnicodeObject *self, PyObject *args) PyErr_Format(PyExc_TypeError, "decoder did not return a string/unicode object " "(type=%.400s)", - v->ob_type->tp_name); + Py_Type(v)->tp_name); Py_DECREF(v); return NULL; } @@ -8134,7 +8133,7 @@ PyObject *PyUnicode_Format(PyObject *format, arglen = -1; argidx = -2; } - if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) && + if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) && !PyObject_TypeCheck(args, &PyBaseString_Type)) dict = args; @@ -8604,8 +8603,7 @@ errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'."); static PyObject *unicode_iter(PyObject *seq); PyTypeObject PyUnicode_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "str", /* tp_name */ sizeof(PyUnicodeObject), /* tp_size */ 0, /* tp_itemsize */ @@ -8902,8 +8900,7 @@ static PyMethodDef unicodeiter_methods[] = { }; PyTypeObject PyUnicodeIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "unicodeiterator", /* tp_name */ sizeof(unicodeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ |