Skip to content

Making instance of TypeVar fails because of missing __name__ #84123

Description

@jack1142
mannequin
BPO 39942
Nosy @ilevkivskyi, @hongweipeng, @miss-islington, @jack1142
PRs
  • bpo-39942:Fix TypeVar fails when missing __name__ #19616
  • [3.7] bpo-39942:Fix failure in TypeVar when missing __name__ (GH-19616) #19626
  • [3.8] bpo-39942:Fix failure in TypeVar when missing __name__ (GH-19616) #19627
  • 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 2020-04-20.20:28:52.865>
    created_at = <Date 2020-03-12.00:11:51.865>
    labels = ['3.7', '3.8', 'type-bug', 'library', '3.9']
    title = 'Making instance of `TypeVar` fails because of missing `__name__`'
    updated_at = <Date 2020-04-20.20:28:52.865>
    user = 'https://github.com/jack1142'

    bugs.python.org fields:

    activity = <Date 2020-04-20.20:28:52.865>
    actor = 'levkivskyi'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-20.20:28:52.865>
    closer = 'levkivskyi'
    components = ['Library (Lib)']
    creation = <Date 2020-03-12.00:11:51.865>
    creator = 'jack1142'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39942
    keywords = ['patch']
    message_count = 4.0
    messages = ['363990', '366872', '366874', '366876']
    nosy_count = 4.0
    nosy_names = ['levkivskyi', 'hongweipeng', 'miss-islington', 'jack1142']
    pr_nums = ['19616', '19626', '19627']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39942'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    Activity

    1. jack1142 commented on Mar 12, 2020

      jack1142mannequin
      MannequinAuthor

      Example code:

      code = """
      import typing
      T = typing.TypeVar("T")
      """
      exec(code, {})
      

      Traceback:

      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "<string>", line 3, in <module>
        File "C:\Python38\lib\typing.py", line 603, in __init__
          def_mod = sys._getframe(1).f_globals['__name__']  # for pickling
      KeyError: '__name__'
      

      If this problem with __name__ is not something that needs to be fixed, then I also noticed that the same line in typing.py will also raise when platform doesn't have sys._getframe()

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Mar 12, 2020
    3. ilevkivskyi commented on Apr 20, 2020

      @ilevkivskyi
      Member

      New changeset a25a04f by HongWeipeng in branch 'master':
      bpo-39942:Fix failure in TypeVar when missing __name__ (GH-19616)
      a25a04f

    4. miss-islington commented on Apr 20, 2020

      @miss-islington
      Contributor

      New changeset 694a95f by Miss Islington (bot) in branch '3.7':
      bpo-39942:Fix failure in TypeVar when missing __name__ (GH-19616)
      694a95f

    5. miss-islington commented on Apr 20, 2020

      @miss-islington
      Contributor

      New changeset 41660ca by Miss Islington (bot) in branch '3.8':
      bpo-39942:Fix failure in TypeVar when missing __name__ (GH-19616)
      41660ca

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions