mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
between runs given the same Grammar.txt input regardless of the hash randomization setting.
This commit is contained in:
commit
0c578d62fc
6 changed files with 116 additions and 16 deletions
|
@ -9,13 +9,13 @@ from textwrap import dedent
|
|||
|
||||
# Local imports
|
||||
from lib2to3 import pytree, refactor
|
||||
from lib2to3.pgen2 import driver
|
||||
from lib2to3.pgen2 import driver as pgen2_driver
|
||||
|
||||
test_dir = os.path.dirname(__file__)
|
||||
proj_dir = os.path.normpath(os.path.join(test_dir, ".."))
|
||||
grammar_path = os.path.join(test_dir, "..", "Grammar.txt")
|
||||
grammar = driver.load_grammar(grammar_path)
|
||||
driver = driver.Driver(grammar, convert=pytree.convert)
|
||||
grammar = pgen2_driver.load_grammar(grammar_path)
|
||||
driver = pgen2_driver.Driver(grammar, convert=pytree.convert)
|
||||
|
||||
def parse_string(string):
|
||||
return driver.parse_string(reformat(string), debug=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue