Ticket #6857: robustapply_pypy_compatible.patch
File robustapply_pypy_compatible.patch, 1.3 KB (added by , 16 years ago) |
---|
-
django/dispatch/robustapply.py
14 14 If fromMethod is true, then the callable already 15 15 has its first argument bound 16 16 """ 17 if hasattr(receiver, '__call__'): 18 # receiver is a class instance; assume it is callable. 19 # Reassign receiver to the actual method that will be called. 20 if hasattr( receiver.__call__, 'im_func') or hasattr( receiver.__call__, 'im_code'): 21 receiver = receiver.__call__ 22 if hasattr( receiver, 'im_func' ): 23 # an instance-method... 17 if hasattr(receiver, 'im_func'): 24 18 return receiver, receiver.im_func.func_code, 1 25 elif not hasattr( receiver, 'func_code'): 19 elif hasattr(receiver, 'func_code'): 20 return receiver, receiver.func_code, 0 21 elif hasattr(receiver, '__call__'): 22 return function(receiver.__call__) 23 else: 26 24 raise ValueError('unknown reciever type %s %s'%(receiver, type(receiver))) 27 return receiver, receiver.func_code, 028 25 29 26 def robustApply(receiver, *arguments, **named): 30 27 """Call receiver with arguments and an appropriate subset of named