@@ -396,6 +396,8 @@ def _has_code_flag(f, flag):
396396 f = f .__func__
397397 f = functools ._unwrap_partial (f )
398398 if not (isfunction (f ) or _signature_is_functionlike (f )):
399+ # If it's not a pure Python function, and not a duck type
400+ # of pure function (Cython and Mock functions, for instance), then:
399401 return False
400402 return bool (f .__code__ .co_flags & flag )
401403
@@ -2334,7 +2336,7 @@ def _signature_from_function(cls, func, skip_bound_arg=True,
23342336 is_duck_function = True
23352337 else :
23362338 # If it's not a pure Python function, and not a duck type
2337- # of pure function:
2339+ # of pure function (Cython and Mock functions, for instance), then :
23382340 raise TypeError ('{!r} is not a Python function' .format (func ))
23392341
23402342 s = getattr (func , "__text_signature__" , None )
@@ -2503,7 +2505,7 @@ def _signature_from_callable(obj, *,
25032505
25042506 if isfunction (obj ) or _signature_is_functionlike (obj ):
25052507 # If it's a pure Python function, or an object that is duck type
2506- # of a Python function (Cython functions, for instance), then:
2508+ # of a Python function (Cython and Mock functions, for instance), then:
25072509 return _signature_from_function (sigcls , obj ,
25082510 skip_bound_arg = skip_bound_arg ,
25092511 globals = globals , locals = locals , eval_str = eval_str )
0 commit comments