diff options
author | Guido van Rossum <guido@python.org> | 2007-10-16 18:12:55 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-16 18:12:55 (GMT) |
commit | 3172c5d263eeffff1e89d03d79be3ccc1d60fbde (patch) | |
tree | a35e103b36b684c4682ded57236199d6a0ecee4b /Objects/stringobject.c | |
parent | 60d241f135f10312f5a638846659d7e471f6cac9 (diff) | |
download | cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.zip cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.gz cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.bz2 |
Patch# 1258 by Christian Heimes: kill basestring.
I like this because it makes the code shorter! :-)
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 83e3cfa..699ae27 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3073,14 +3073,6 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } static PyObject * -basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyErr_SetString(PyExc_TypeError, - "The basestring type cannot be instantiated"); - return NULL; -} - -static PyObject * string_mod(PyObject *v, PyObject *w) { if (!PyString_Check(v)) { @@ -3090,9 +3082,6 @@ string_mod(PyObject *v, PyObject *w) return PyString_Format(v, w); } -PyDoc_STRVAR(basestring_doc, -"Type basestring cannot be instantiated; it is the base for str8 and str."); - static PyNumberMethods string_as_number = { 0, /*nb_add*/ 0, /*nb_subtract*/ @@ -3100,49 +3089,6 @@ static PyNumberMethods string_as_number = { string_mod, /*nb_remainder*/ }; - -PyTypeObject PyBaseString_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "basestring", - 0, - 0, - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - basestring_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyBaseObject_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - basestring_new, /* tp_new */ - 0, /* tp_free */ -}; - PyDoc_STRVAR(string_doc, "str(object) -> string\n\ \n\ @@ -3183,7 +3129,7 @@ PyTypeObject PyString_Type = { string_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - &PyBaseString_Type, /* tp_base */ + &PyBaseObject_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -3615,7 +3561,7 @@ PyString_Format(PyObject *format, PyObject *args) argidx = -2; } if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) && - !PyObject_TypeCheck(args, &PyBaseString_Type)) + !PyString_Check(args) && !PyUnicode_Check(args)) dict = args; while (--fmtcnt >= 0) { if (*fmt != '%') { |