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

lib2to3 fails on default convert functionality #84282

Closed
isidentical opened this issue Mar 29, 2020 · 2 comments
Closed

lib2to3 fails on default convert functionality #84282

isidentical opened this issue Mar 29, 2020 · 2 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@isidentical
Copy link
Sponsor Member

BPO 40101
Nosy @isidentical
PRs
  • bpo-40101: Fix parser's assumption about the return value of convert #19214
  • 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 = None
    created_at = <Date 2020-03-29.15:24:48.719>
    labels = ['library', '3.9']
    title = 'lib2to3 fails on default convert functionality'
    updated_at = <Date 2020-03-29.15:30:56.173>
    user = 'https://github.com/isidentical'

    bugs.python.org fields:

    activity = <Date 2020-03-29.15:30:56.173>
    actor = 'BTaskaya'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-03-29.15:24:48.719>
    creator = 'BTaskaya'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40101
    keywords = ['patch']
    message_count = 1.0
    messages = ['365260']
    nosy_count = 1.0
    nosy_names = ['BTaskaya']
    pr_nums = ['19214']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40101'
    versions = ['Python 3.9']

    @isidentical
    Copy link
    Sponsor Member Author

    When using driver/parser without a custom convert function (like pyconvert.convert), it tries to assign used_names to the root node, which can be anything depending on the given convert function. If none given, it will be a tuple.

    >>> from lib2to3.pygram import python_grammar
    >>> from lib2to3.pgen2.driver import Driver
    >>> 
    >>> d = Driver(grammar=python_grammar)
    >>> d.parse_string("test\n")
    Traceback (most recent call la
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.9/lib2to3/pgen2/driver.py", line 103, in parse_string
        return self.parse_tokens(tokens, debug)
      File "/usr/local/lib/python3.9/lib2to3/pgen2/driver.py", line 71, in parse_tokens
        if p.addtoken(type, value, (prefix, start)):
      File "/usr/local/lib/python3.9/lib2to3/pgen2/parse.py", line 136, in addtoken
        self.pop()
      File "/usr/local/lib/python3.9/lib2to3/pgen2/parse.py", line 204, in pop
        self.rootnode.used_names = self.used_names
    AttributeError: 'tuple' object has no attribute 'used_names'

    @isidentical isidentical added 3.9 only security fixes stdlib Python modules in the Lib dir labels Mar 29, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added the pending The issue will be closed if no feedback is provided label Jun 24, 2022
    @iritkatriel
    Copy link
    Member

    lib2to3 is deprecated. Is this still relevant?

    @kumaraditya303 kumaraditya303 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 12, 2022
    @erlend-aasland erlend-aasland removed the pending The issue will be closed if no feedback is provided label Jul 20, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants