@@ -114,7 +114,7 @@ builtin_buffer(PyObject *self, PyObject *args)
114114static char buffer_doc [] =
115115"buffer(object [, offset[, size]]) -> object\n\
116116\n\
117- Creates a new buffer object which references the given object.\n\
117+ Create a new buffer object which references the given object.\n\
118118The buffer will reference a slice of the target object from the\n\
119119start of the object (or at the specified offset). The slice will\n\
120120extend to the end of the target object (or with the specified size)." ;
@@ -135,7 +135,7 @@ builtin_unicode(PyObject *self, PyObject *args)
135135static char unicode_doc [] =
136136"unicode(string [, encoding[, errors]]) -> object\n\
137137\n\
138- Creates a new Unicode object from the given encoded string.\n\
138+ Create a new Unicode object from the given encoded string.\n\
139139encoding defaults to the current default string encoding and \n\
140140errors, defining the error handling, to 'strict'." ;
141141
@@ -411,9 +411,9 @@ complex_from_string(PyObject *v)
411411 "complex() literal too large to convert" );
412412 return NULL ;
413413 }
414- if (PyUnicode_EncodeDecimal (PyUnicode_AS_UNICODE (v ),
414+ if (PyUnicode_EncodeDecimal (PyUnicode_AS_UNICODE (v ),
415415 PyUnicode_GET_SIZE (v ),
416- s_buffer ,
416+ s_buffer ,
417417 NULL ))
418418 return NULL ;
419419 s = s_buffer ;
@@ -438,7 +438,7 @@ complex_from_string(PyObject *v)
438438 z = -1.0 ;
439439 sign = 1 ;
440440 do {
441-
441+
442442 switch (* s ) {
443443
444444 case '\0' :
@@ -450,7 +450,7 @@ complex_from_string(PyObject *v)
450450 }
451451 if (!done ) sw_error = 1 ;
452452 break ;
453-
453+
454454 case '-' :
455455 sign = -1 ;
456456 /* Fallthrough */
@@ -509,7 +509,7 @@ complex_from_string(PyObject *v)
509509 }
510510 s = end ;
511511 if (* s == 'J' || * s == 'j' ) {
512-
512+
513513 break ;
514514 }
515515 if (got_re ) {
@@ -524,7 +524,7 @@ complex_from_string(PyObject *v)
524524 z = -1.0 ;
525525 sign = 1 ;
526526 break ;
527-
527+
528528 } /* end of switch */
529529
530530 } while (* s != '\0' && !sw_error );
@@ -935,7 +935,7 @@ builtin_map(PyObject *self, PyObject *args)
935935 for (len = 0 , i = 0 , sqp = seqs ; i < n ; ++ i , ++ sqp ) {
936936 int curlen ;
937937 PySequenceMethods * sqf ;
938-
938+
939939 if ((sqp -> seq = PyTuple_GetItem (args , i + 1 )) == NULL )
940940 goto Fail_2 ;
941941
@@ -1135,7 +1135,7 @@ builtin_hex(PyObject *self, PyObject *args)
11351135
11361136 if (!PyArg_ParseTuple (args , "O:hex" , & v ))
11371137 return NULL ;
1138-
1138+
11391139 if ((nb = v -> ob_type -> tp_as_number ) == NULL ||
11401140 nb -> nb_hex == NULL ) {
11411141 PyErr_SetString (PyExc_TypeError ,
@@ -1244,7 +1244,7 @@ builtin_long(PyObject *self, PyObject *args)
12441244{
12451245 PyObject * v ;
12461246 int base = -909 ; /* unlikely! */
1247-
1247+
12481248 if (!PyArg_ParseTuple (args , "O|i:long" , & v , & base ))
12491249 return NULL ;
12501250 if (base == -909 )
@@ -1529,7 +1529,7 @@ builtin_ord(PyObject *self, PyObject *args)
15291529 return NULL ;
15301530 }
15311531
1532- PyErr_Format (PyExc_TypeError ,
1532+ PyErr_Format (PyExc_TypeError ,
15331533 "ord() expected a character, "
15341534 "but string of length %d found" ,
15351535 size );
@@ -1539,7 +1539,7 @@ builtin_ord(PyObject *self, PyObject *args)
15391539static char ord_doc [] =
15401540"ord(c) -> integer\n\
15411541\n\
1542- Return the integer ordinal of a one character string." ;
1542+ Return the integer ordinal of a one- character string." ;
15431543
15441544
15451545static PyObject *
@@ -2014,9 +2014,9 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
20142014 if (first ) {
20152015 bases = PyObject_GetAttr (cls , __bases__ );
20162016 if (bases == NULL || !PyTuple_Check (bases )) {
2017- Py_XDECREF (bases );
2018- PyErr_SetString (PyExc_TypeError ,
2019- "arg 2 must be a class or type " );
2017+ Py_XDECREF (bases );
2018+ PyErr_SetString (PyExc_TypeError ,
2019+ "issubclass() arg 2 must be a class" );
20202020 return -1 ;
20212021 }
20222022 Py_DECREF (bases );
@@ -2029,7 +2029,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls, int first)
20292029 if (bases == NULL || !PyTuple_Check (bases )) {
20302030 Py_XDECREF (bases );
20312031 PyErr_SetString (PyExc_TypeError ,
2032- "arg 2 must be a class or type " );
2032+ "issubclass() arg 1 must be a class" );
20332033 return -1 ;
20342034 }
20352035
@@ -2068,23 +2068,29 @@ builtin_isinstance(PyObject *self, PyObject *args)
20682068 retval = ((PyObject * )(inst -> ob_type ) == cls );
20692069 }
20702070 else if (!PyInstance_Check (inst )) {
2071- if (__class__ == NULL ) {
2071+ if (__class__ == NULL ) {
20722072 __class__ = PyString_FromString ("__class__" );
20732073 if (__class__ == NULL )
20742074 return NULL ;
20752075 }
20762076 icls = PyObject_GetAttr (inst , __class__ );
20772077 if (icls != NULL ) {
2078- retval = abstract_issubclass ( icls , cls , 1 );
2078+ retval = abstract_issubclass (icls , cls , 1 );
20792079 Py_DECREF (icls );
2080- if (retval < 0 )
2080+ if (retval < 0 &&
2081+ !PyErr_ExceptionMatches (PyExc_TypeError ))
20812082 return NULL ;
20822083 }
2083- else {
2084- PyErr_SetString (PyExc_TypeError ,
2085- "arg 2 must be a class or type" );
2086- return NULL ;
2087- }
2084+ else
2085+ retval = -1 ;
2086+ }
2087+ else
2088+ retval = -1 ;
2089+
2090+ if (retval < 0 ) {
2091+ PyErr_SetString (PyExc_TypeError ,
2092+ "isinstance() arg 2 must be a class or type" );
2093+ return NULL ;
20882094 }
20892095 return PyInt_FromLong (retval );
20902096}
@@ -2108,7 +2114,7 @@ builtin_issubclass(PyObject *self, PyObject *args)
21082114
21092115 if (!PyClass_Check (derived ) || !PyClass_Check (cls )) {
21102116 retval = abstract_issubclass (derived , cls , 1 );
2111- if (retval < 0 )
2117+ if (retval < 0 )
21122118 return NULL ;
21132119 }
21142120 else {
@@ -2261,7 +2267,7 @@ _PyBuiltin_Init(void)
22612267 return NULL ;
22622268 if (PyDict_SetItemString (dict , "Ellipsis" , Py_Ellipsis ) < 0 )
22632269 return NULL ;
2264- if (PyDict_SetItemString (dict , "NotImplemented" ,
2270+ if (PyDict_SetItemString (dict , "NotImplemented" ,
22652271 Py_NotImplemented ) < 0 )
22662272 return NULL ;
22672273 debug = PyInt_FromLong (Py_OptimizeFlag == 0 );
0 commit comments