mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
(Modified) patch by Ping - SF Patch #102681.
- Make error messages from issubclass() and isinstance() a bit more descriptive (Ping, modified by Guido) - Couple of tiny fixes to other docstrings (Ping) - Get rid of trailing whitespace (Guido)
This commit is contained in:
parent
234fb632a3
commit
ad991775ab
1 changed files with 33 additions and 27 deletions
|
@ -114,7 +114,7 @@ builtin_buffer(PyObject *self, PyObject *args)
|
||||||
static char buffer_doc[] =
|
static char buffer_doc[] =
|
||||||
"buffer(object [, offset[, size]]) -> object\n\
|
"buffer(object [, offset[, size]]) -> object\n\
|
||||||
\n\
|
\n\
|
||||||
Creates a new buffer object which references the given object.\n\
|
Create a new buffer object which references the given object.\n\
|
||||||
The buffer will reference a slice of the target object from the\n\
|
The buffer will reference a slice of the target object from the\n\
|
||||||
start of the object (or at the specified offset). The slice will\n\
|
start of the object (or at the specified offset). The slice will\n\
|
||||||
extend to the end of the target object (or with the specified size).";
|
extend to the end of the target object (or with the specified size).";
|
||||||
|
@ -135,7 +135,7 @@ builtin_unicode(PyObject *self, PyObject *args)
|
||||||
static char unicode_doc[] =
|
static char unicode_doc[] =
|
||||||
"unicode(string [, encoding[, errors]]) -> object\n\
|
"unicode(string [, encoding[, errors]]) -> object\n\
|
||||||
\n\
|
\n\
|
||||||
Creates a new Unicode object from the given encoded string.\n\
|
Create a new Unicode object from the given encoded string.\n\
|
||||||
encoding defaults to the current default string encoding and \n\
|
encoding defaults to the current default string encoding and \n\
|
||||||
errors, defining the error handling, to 'strict'.";
|
errors, defining the error handling, to 'strict'.";
|
||||||
|
|
||||||
|
@ -1539,7 +1539,7 @@ builtin_ord(PyObject *self, PyObject *args)
|
||||||
static char ord_doc[] =
|
static char ord_doc[] =
|
||||||
"ord(c) -> integer\n\
|
"ord(c) -> integer\n\
|
||||||
\n\
|
\n\
|
||||||
Return the integer ordinal of a one character string.";
|
Return the integer ordinal of a one-character string.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -2016,7 +2016,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
|
||||||
if (bases == NULL || !PyTuple_Check(bases)) {
|
if (bases == NULL || !PyTuple_Check(bases)) {
|
||||||
Py_XDECREF(bases);
|
Py_XDECREF(bases);
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"arg 2 must be a class or type");
|
"issubclass() arg 2 must be a class");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_DECREF(bases);
|
Py_DECREF(bases);
|
||||||
|
@ -2029,7 +2029,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
|
||||||
if (bases == NULL || !PyTuple_Check(bases)) {
|
if (bases == NULL || !PyTuple_Check(bases)) {
|
||||||
Py_XDECREF(bases);
|
Py_XDECREF(bases);
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"arg 2 must be a class or type");
|
"issubclass() arg 1 must be a class");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2075,17 +2075,23 @@ builtin_isinstance(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
icls = PyObject_GetAttr(inst, __class__);
|
icls = PyObject_GetAttr(inst, __class__);
|
||||||
if (icls != NULL) {
|
if (icls != NULL) {
|
||||||
retval = abstract_issubclass( icls, cls, 1);
|
retval = abstract_issubclass(icls, cls, 1);
|
||||||
Py_DECREF(icls);
|
Py_DECREF(icls);
|
||||||
if (retval < 0)
|
if (retval < 0 &&
|
||||||
|
!PyErr_ExceptionMatches(PyExc_TypeError))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
retval = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
retval = -1;
|
||||||
|
|
||||||
|
if (retval < 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"arg 2 must be a class or type");
|
"isinstance() arg 2 must be a class or type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return PyInt_FromLong(retval);
|
return PyInt_FromLong(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue