This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: lib2to3 fails on default convert functionality
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya
Priority: normal Keywords: patch

Created on 2020-03-29 15:24 by BTaskaya, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 19214 open BTaskaya, 2020-03-29 15:30
Messages (1)
msg365260 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-03-29 15:24
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'
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84282
2020-03-29 15:30:56BTaskayasetkeywords: + patch
stage: patch review
pull_requests: + pull_request18578
2020-03-29 15:24:48BTaskayacreate