[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-12 Thread Iliya Zinoviev


Iliya Zinoviev  added the comment:

I suppose isgeneratorfunction,
iscoroutinefunction, isasyncgenfunction were modified to treat partial obj like 
regular function. But then without modifying isfunction as well, this approach 
won't work in full measure.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-12 Thread Iliya Zinoviev


Iliya Zinoviev  added the comment:

Kevin, thanks for answer!

In that case, I may conclude isgeneratorfunction,
iscoroutinefunction, isasyncgenfunction from python3.7 are more determinated, 
in my view, cause partial obj has `func` attr for interaction with these funcs 
anyway, so it isn't need of an alternative.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-11 Thread Kevin Shweh


Kevin Shweh  added the comment:

Frankly, it doesn't make sense that isgeneratorfunction or iscoroutinefunction 
unwrap partials at all. The original justification for making them do that back 
in https://bugs.python.org/issue34890 was invalid - the original argument was 
that isfunction unwraps partials, but it doesn't, and I don't think it ever did.

isfunction is supposed to be a very specific check for Python function objects. 
It rejects all sorts of other callables, like sum (a built-in function), super 
(a type), or method objects (which wrap functions in a very similar way to 
partial). Having it be a check for *either* a Python function object *or* a 
partial object wrapping a Python function object seems to just make it less 
useful.

--
nosy: +Kevin Shweh

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-11 Thread Iliya Zinoviev


Change by Iliya Zinoviev :


Removed file: https://bugs.python.org/file50622/isfuncs_behavior.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-11 Thread Iliya Zinoviev


Change by Iliya Zinoviev :


Added file: https://bugs.python.org/file50622/isfuncs_behavior.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46722] Different behavior for functiools.partial between inspect.isfunction() and other inspect.is*function()

2022-02-11 Thread Iliya Zinoviev

New submission from Iliya Zinoviev :

1) isfunction() returns `True` for partial object only when one passes `func` 
attribute of it.
2) For instance, `isgeneratorfunction()` and `iscoroutinefunction()` for 
partial obj work with passing partial obj as well as with passing `func` attr 
of this obj, when obj is partially applied generator function or partially 
applied coroutine function respectively.

I offer to unify behavior for handling partial object for 
r'inspect.is*function()' by the next way:
1) Add `functools._unwrap_partial()` to `inspect.isfunction()` as well as it 
were done in other r'inspect.is*function()'.

P.S.I'm ready to deal with this issue.  

Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
Type 'copyright', 'credits' or 'license' for more information

Operating System: Manjaro Linux
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.4.176-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-6200U CPU @ 2.30GHz
Memory: 11.6 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 520

--
components: Library (Lib)
files: isfuncs_behavior.py
messages: 413077
nosy: IliyaZinoviev
priority: normal
severity: normal
status: open
title: Different behavior for functiools.partial between inspect.isfunction() 
and other inspect.is*function()
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50621/isfuncs_behavior.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com