@@ -1402,7 +1402,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
14021402 case BREAK_LOOP :
14031403 why = WHY_BREAK ;
14041404 break ;
1405-
1405+
14061406 case CONTINUE_LOOP :
14071407 retval = PyInt_FromLong (oparg );
14081408 why = WHY_CONTINUE ;
@@ -2181,7 +2181,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
21812181 if (b -> b_type == SETUP_LOOP && why == WHY_CONTINUE ) {
21822182 /* For a continue inside a try block,
21832183 don't pop the block for the loop. */
2184- PyFrame_BlockSetup (f , b -> b_type , b -> b_level ,
2184+ PyFrame_BlockSetup (f , b -> b_type , b -> b_level ,
21852185 b -> b_handler );
21862186 why = WHY_NOT ;
21872187 JUMPTO (PyInt_AS_LONG (retval ));
@@ -2825,22 +2825,28 @@ call_method(PyObject *func, PyObject *arg, PyObject *kw)
28252825 if (self == NULL ) {
28262826 /* Unbound methods must be called with an instance of
28272827 the class (or a derived class) as first argument */
2828+ int ok ;
28282829 if (PyTuple_Size (arg ) >= 1 )
28292830 self = PyTuple_GET_ITEM (arg , 0 );
2830- if (!(self != NULL && PyInstance_Check (self )
2831- && PyClass_IsSubclass ((PyObject * )
2832- (((PyInstanceObject * )self )-> in_class ),
2833- class ))) {
2834- PyObject * fn = ((PyFunctionObject * ) func )-> func_name ;
2835- PyErr_Format (PyExc_TypeError ,
2836- "unbound method %s%smust be "
2837- "called with instance as first argument" ,
2838- fn ? PyString_AsString (fn ) : "" ,
2839- fn ? "() " : "" );
2831+ if (self == NULL )
2832+ ok = 0 ;
2833+ else {
2834+ ok = PyObject_IsInstance (self , class );
2835+ if (ok < 0 )
2836+ return NULL ;
2837+ }
2838+ if (!ok ) {
2839+ PyObject * fn = ((PyFunctionObject * ) func )-> func_name ;
2840+ PyErr_Format (PyExc_TypeError ,
2841+ "unbound method %s%smust be "
2842+ "called with instance as first argument" ,
2843+ fn ? PyString_AsString (fn ) : "" ,
2844+ fn ? "() " : "" );
28402845 return NULL ;
28412846 }
28422847 Py_INCREF (arg );
2843- } else {
2848+ }
2849+ else {
28442850 int argcount = PyTuple_Size (arg );
28452851 PyObject * newarg = PyTuple_New (argcount + 1 );
28462852 int i ;
0 commit comments