classification
Title: __qualname__ different when calling generator object w/ functions.partial
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, brett.cannon, corona10, dino.viehland, xtreak
Priority: normal Keywords:

Created on 2016-01-12 22:33 by dino.viehland, last changed 2019-10-03 18:12 by corona10. This issue is now closed.

Messages (3)
msg258119 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2016-01-12 22:33
import functools
def f():
    def g():
        yield 1
    return g

functools.partial(f())().__qualname__ != f()().__qualname__

The qualified name gets passed in via the interpreter loop with _PyEval_EvalCodeWithName calling PyGen_NewWithQualName.  If a generator object gets called from C then the qualified name gets lost.

It seems like _PyEval_EvalCodeWithName shouldn't exist and the generator code object should be able to get back to its qualified name so subtle differences like this don't happen.
msg350396 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2019-08-24 19:16
This bug is fixed in 3.9 (probably in 3.8 too)
msg353870 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2019-10-03 18:12
Python 3.9.0a0 (heads/bpo-31722:fc4a044a3c, Oct  4 2019, 03:10:14)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>> def f():
...     def g():
...         yield 1
...     return g
...
>>> functools.partial(f())().__qualname__ == f()().__qualname__
True
>>> functools.partial(f())().__qualname__
'f.<locals>.g'
>>> f()().__qualname__
'f.<locals>.g'

Looks like that this issue is fixed
History
Date User Action Args
2019-10-03 18:12:30corona10setstatus: open -> closed

nosy: + corona10
messages: + msg353870

resolution: fixed
stage: resolved
2019-08-24 19:16:12BTaskayasetnosy: + BTaskaya
messages: + msg350396
2018-09-10 06:10:58xtreaksetnosy: + xtreak
2016-01-13 17:42:51brett.cannonsetnosy: + brett.cannon
2016-01-12 22:33:48dino.viehlandcreate