(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:
Guido van Rossum 2001-01-12 16:03:05 +00:00
parent 234fb632a3
commit ad991775ab
1 changed files with 33 additions and 27 deletions

View File

@ -114,7 +114,7 @@ builtin_buffer(PyObject *self, PyObject *args)
static char buffer_doc[] =
"buffer(object [, offset[, size]]) -> object\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\
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).";
@ -135,7 +135,7 @@ builtin_unicode(PyObject *self, PyObject *args)
static char unicode_doc[] =
"unicode(string [, encoding[, errors]]) -> object\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\
errors, defining the error handling, to 'strict'.";
@ -1539,7 +1539,7 @@ builtin_ord(PyObject *self, PyObject *args)
static char ord_doc[] =
"ord(c) -> integer\n\
\n\
Return the integer ordinal of a one character string.";
Return the integer ordinal of a one-character string.";
static PyObject *
@ -2016,7 +2016,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
if (bases == NULL || !PyTuple_Check(bases)) {
Py_XDECREF(bases);
PyErr_SetString(PyExc_TypeError,
"arg 2 must be a class or type");
"issubclass() arg 2 must be a class");
return -1;
}
Py_DECREF(bases);
@ -2029,7 +2029,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
if (bases == NULL || !PyTuple_Check(bases)) {
Py_XDECREF(bases);
PyErr_SetString(PyExc_TypeError,
"arg 2 must be a class or type");
"issubclass() arg 1 must be a class");
return -1;
}
@ -2075,17 +2075,23 @@ builtin_isinstance(PyObject *self, PyObject *args)
}
icls = PyObject_GetAttr(inst, __class__);
if (icls != NULL) {
retval = abstract_issubclass( icls, cls, 1);
retval = abstract_issubclass(icls, cls, 1);
Py_DECREF(icls);
if (retval < 0)
if (retval < 0 &&
!PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
}
else {
else
retval = -1;
}
else
retval = -1;
if (retval < 0) {
PyErr_SetString(PyExc_TypeError,
"arg 2 must be a class or type");
"isinstance() arg 2 must be a class or type");
return NULL;
}
}
return PyInt_FromLong(retval);
}