[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-07 Thread Terry J. Reedy
Terry J. Reedy added the comment: If you want to know if a function returns a generator, you have to call it and pass the result to *isgenerator*, or use type-annotated functions (see the typing module) and static type checkers. -- ___ Python tracke

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-07 Thread Terry J. Reedy
Terry J. Reedy added the comment: A generator function *gf* is a function that contain *yield* in its body. When it is compiled, flag CO_GENERATOR is set in gf.__code__.co_flags. When the function is called, the flag is queried and if set, a special path is taken that attaches the live but s

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-05 Thread Martin Panter
Martin Panter added the comment: Not in general. I think you would have to make special cases for partial functions, __wrapped__, and whatever else there is, and combinations of these. It would be very hard to determine the correct result for test2 in test2 = lambda: test(a=10) # test2() retu

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-04 Thread Thomas Antony
Thomas Antony added the comment: Is there any way to distinguish such callables from "normal" functions without actually calling them? -- ___ Python tracker ___

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-04 Thread Martin Panter
Martin Panter added the comment: Doesn't seem like a bug to me. Even if there was special support for "partial" objects, that won't help with other ways of producing the same sort of thing. test2 = functools.partial(test, a=10) @functools.wraps(test) def test2(): return test(a=10) Both w

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-04 Thread Thomas Antony
Changes by Thomas Antony : -- versions: +Python 3.6 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue29987] inspect.isgeneratorfunction not working with partial functions

2017-04-04 Thread Thomas Antony
New submission from Thomas Antony: When inspect.isgeneratorfunction is called on the output of functools.partial, it returns False even if the original function was a generator function. Test case is attached. Tested in fresh conda environment running Python 3.6.1 -- files: testcode.