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

Add __name__ in globals of generated namedtuple namespace #47152

Closed
xilun mannequin opened this issue May 18, 2008 · 2 comments
Closed

Add __name__ in globals of generated namedtuple namespace #47152

xilun mannequin opened this issue May 18, 2008 · 2 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@xilun
Copy link
Mannequin

xilun mannequin commented May 18, 2008

BPO 2903
Nosy @rhettinger
Files
  • collections.r59898.patch
  • 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 = 'https://github.com/rhettinger'
    closed_at = <Date 2008-05-30.07:19:18.670>
    created_at = <Date 2008-05-18.03:12:28.618>
    labels = ['library']
    title = 'Add __name__ in globals of generated namedtuple namespace'
    updated_at = <Date 2008-05-30.07:19:18.625>
    user = 'https://bugs.python.org/xilun'

    bugs.python.org fields:

    activity = <Date 2008-05-30.07:19:18.625>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2008-05-30.07:19:18.670>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2008-05-18.03:12:28.618>
    creator = 'xilun'
    dependencies = []
    files = ['10361']
    hgrepos = []
    issue_num = 2903
    keywords = ['patch']
    message_count = 2.0
    messages = ['67022', '67523']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'xilun']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue2903'
    versions = ['Python 2.6']

    @xilun
    Copy link
    Mannequin Author

    xilun mannequin commented May 18, 2008

    Some 3rd party tracers rely on frame.f_globals["__name__"] to be set to
    the module name that contains the code currently executed.
    frame.f_globals["__name__"] is not defined when some code has been
    generated with exec, which is the way namedtuples are created.

    The attached patch set __name__ to '__generated_%s__' % typename in the
    generated namespace, which is quite handy to see where the code comes
    from. Indeed if sys._getframe is available it sets __name__ to
    '__generated_%s__%s__' % (typename, result.__module__) which is even
    more useful.

    @xilun xilun mannequin added the stdlib Python modules in the Lib dir label May 18, 2008
    @rhettinger
    Copy link
    Contributor

    Added the simpler first part of the patch in r63807.
    Thanks for the submission.

    @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
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant