Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__qualname__ different when calling generator object w/ functions.partial #70281

Closed
DinoV opened this issue Jan 12, 2016 · 3 comments
Closed
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@DinoV
Copy link
Contributor

DinoV commented Jan 12, 2016

BPO 26093
Nosy @brettcannon, @DinoV, @corona10, @tirkarthi, @isidentical

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-10-03.18:12:30.026>
created_at = <Date 2016-01-12.22:33:48.049>
labels = ['interpreter-core', 'type-bug']
title = '__qualname__ different when calling generator object w/ functions.partial'
updated_at = <Date 2019-10-03.18:12:30.023>
user = 'https://github.com/DinoV'

bugs.python.org fields:

activity = <Date 2019-10-03.18:12:30.023>
actor = 'corona10'
assignee = 'none'
closed = True
closed_date = <Date 2019-10-03.18:12:30.026>
closer = 'corona10'
components = ['Interpreter Core']
creation = <Date 2016-01-12.22:33:48.049>
creator = 'dino.viehland'
dependencies = []
files = []
hgrepos = []
issue_num = 26093
keywords = []
message_count = 3.0
messages = ['258119', '350396', '353870']
nosy_count = 5.0
nosy_names = ['brett.cannon', 'dino.viehland', 'corona10', 'xtreak', 'BTaskaya']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue26093'
versions = ['Python 3.5']

@DinoV
Copy link
Contributor Author

DinoV commented Jan 12, 2016

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.

@DinoV DinoV added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jan 12, 2016
@isidentical
Copy link
Sponsor Member

This bug is fixed in 3.9 (probably in 3.8 too)

@corona10
Copy link
Member

corona10 commented Oct 3, 2019

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

@corona10 corona10 closed this as completed Oct 3, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants