Skip to content

Tools/peg_generator/pegen fails in python mode with python.gram in branch 3.10 #104365

Closed as not planned
@noahbkim

Description

@noahbkim

Bug report

The pegen utility raises when building Grammar/python.gram in the 3.10 branch:

$ make -j
$ cd Tools/peg_generator
$ ../../python -m pegen -v python ../../Grammar/python.gram
Traceback (most recent call last):
  File "/usr/scratch/noah/python/Lib/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/scratch/noah/python/Lib/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/__main__.py", line 185, in <module>
    main()
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/__main__.py", line 129, in main
    grammar, parser, tokenizer, gen = args.func(args)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/__main__.py", line 58, in generate_python_code
    grammar, parser, tokenizer, gen = build_python_parser_and_generator(
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/build.py", line 259, in build_python_parser_and_generator
    gen = build_python_generator(grammar, grammar_file, output_file, skip_actions=skip_actions,)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/build.py", line 192, in build_python_generator
    gen.generate(grammar_file)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/python_generator.py", line 154, in generate
    self.visit(rule)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/grammar.py", line 32, in visit
    return visitor(node, *args, **kwargs)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/python_generator.py", line 181, in visit_Rule
    self.visit(rhs, is_loop=is_loop, is_gather=is_gather)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/grammar.py", line 32, in visit
    return visitor(node, *args, **kwargs)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/python_generator.py", line 202, in visit_Rhs
    self.visit(alt, is_loop=is_loop, is_gather=is_gather)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/grammar.py", line 32, in visit
    return visitor(node, *args, **kwargs)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/python_generator.py", line 218, in visit_Alt
    self.visit(item)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/grammar.py", line 32, in visit
    return visitor(node, *args, **kwargs)
  File "/usr/scratch/noah/python/Tools/peg_generator/pegen/python_generator.py", line 188, in visit_NamedItem
    name, call = self.callmakervisitor.visit(node.item)
TypeError: cannot unpack non-iterable NoneType object

Your environment

  • CPython versions tested on: this is on the latest commit to the 3.10 branch,
  • Operating system and architecture: this happens on Debian GNU/Linux 10 but I cannot reproduce it on macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions