[Python-Dev] Need a way to test for 8-bit-or-unicode-string (original) (raw)
Guido van Rossum guido@python.org
Fri, 05 Oct 2001 11:46:57 -0400
- Previous message: [Python-Dev] Need a way to test for 8-bit-or-unicode-string
- Next message: [Python-Dev] Need a way to test for 8-bit-or-unicode-string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Here's an implementation of Neil's idea.
*** abstract.c 2001/10/01 17:10:18 2.83 --- abstract.c 2001/10/05 15:49:04
*** 1805,1810 **** --- 1805,1829 ---- else if (PyType_Check(cls)) { retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls); }
else if (PySequence_Check(cls)) {
int i, n;
cls = PySequence_Fast(
cls, "isinstance() arg 2 is an unacceptable sequence");
if (cls == NULL)
return -1;
n = PySequence_Size(cls);
if (n < 0)
retval = -1;
for (i = 0; i < n; i++) {
retval = PyObject_IsInstance(
inst, PySequence_Fast_GET_ITEM(cls, i));
if (retval != 0)
break;
}
Py_DECREF(cls);
return retval;
} else if (!PyInstance_Check(inst)) { if (__class__ == NULL) { __class__ = PyString_FromString("__class__");
*** 1827,1833 ****
if (retval < 0) {
PyErr_SetString(PyExc_TypeError,
! "isinstance() arg 2 must be a class or type"); } return retval; } --- 1846,1853 ----
if (retval < 0) {
PyErr_SetString(PyExc_TypeError,
! "isinstance() arg 2 must be a class or type " ! "or tuple of those"); } return retval; }
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Need a way to test for 8-bit-or-unicode-string
- Next message: [Python-Dev] Need a way to test for 8-bit-or-unicode-string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]