mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
Change name from string to basestring
This commit is contained in:
parent
9b414ac93e
commit
32a7e7f6b6
@ -12,10 +12,10 @@ Core and builtins
|
|||||||
deprecations, use -Walways::PendingDeprecationWarning::
|
deprecations, use -Walways::PendingDeprecationWarning::
|
||||||
as a command line option or warnings.filterwarnings() in code.
|
as a command line option or warnings.filterwarnings() in code.
|
||||||
|
|
||||||
- A new type object, 'string', is added. This is a common base type
|
- A new type object, 'basestring', is added. This is a common base type
|
||||||
for 'str' and 'unicode', and can be used instead of
|
for 'str' and 'unicode', and can be used instead of
|
||||||
types.StringTypes, e.g. to test whether something is "a string":
|
types.StringTypes, e.g. to test whether something is "a string":
|
||||||
isinstance(x, string) is True for Unicode and 8-bit strings. This
|
isinstance(x, basestring) is True for Unicode and 8-bit strings. This
|
||||||
is an abstract base class and cannot be instantiated directly.
|
is an abstract base class and cannot be instantiated directly.
|
||||||
|
|
||||||
- Deprecated features of xrange objects have been removed as
|
- Deprecated features of xrange objects have been removed as
|
||||||
|
@ -2859,17 +2859,17 @@ static PyObject *
|
|||||||
basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"The string type cannot be instantiated");
|
"The basestring type cannot be instantiated");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char basestring_doc[] =
|
static char basestring_doc[] =
|
||||||
"Type string cannot be instantiated; it is the base for str and unicode.";
|
"Type basestring cannot be instantiated; it is the base for str and unicode.";
|
||||||
|
|
||||||
PyTypeObject PyBaseString_Type = {
|
PyTypeObject PyBaseString_Type = {
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
PyObject_HEAD_INIT(&PyType_Type)
|
||||||
0,
|
0,
|
||||||
"string",
|
"basestring",
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0, /* tp_dealloc */
|
0, /* tp_dealloc */
|
||||||
|
@ -1890,6 +1890,7 @@ _PyBuiltin_Init(void)
|
|||||||
SETBUILTIN("NotImplemented", Py_NotImplemented);
|
SETBUILTIN("NotImplemented", Py_NotImplemented);
|
||||||
SETBUILTIN("False", Py_False);
|
SETBUILTIN("False", Py_False);
|
||||||
SETBUILTIN("True", Py_True);
|
SETBUILTIN("True", Py_True);
|
||||||
|
SETBUILTIN("basestring", &PyBaseString_Type);
|
||||||
SETBUILTIN("bool", &PyBool_Type);
|
SETBUILTIN("bool", &PyBool_Type);
|
||||||
SETBUILTIN("classmethod", &PyClassMethod_Type);
|
SETBUILTIN("classmethod", &PyClassMethod_Type);
|
||||||
#ifndef WITHOUT_COMPLEX
|
#ifndef WITHOUT_COMPLEX
|
||||||
@ -1905,7 +1906,6 @@ _PyBuiltin_Init(void)
|
|||||||
SETBUILTIN("object", &PyBaseObject_Type);
|
SETBUILTIN("object", &PyBaseObject_Type);
|
||||||
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
|
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
|
||||||
SETBUILTIN("str", &PyString_Type);
|
SETBUILTIN("str", &PyString_Type);
|
||||||
SETBUILTIN("string", &PyBaseString_Type);
|
|
||||||
SETBUILTIN("super", &PySuper_Type);
|
SETBUILTIN("super", &PySuper_Type);
|
||||||
SETBUILTIN("tuple", &PyTuple_Type);
|
SETBUILTIN("tuple", &PyTuple_Type);
|
||||||
SETBUILTIN("type", &PyType_Type);
|
SETBUILTIN("type", &PyType_Type);
|
||||||
|
Loading…
Reference in New Issue
Block a user