[Python-checkins] gh-99016: Make build scripts compatible with Python 3.8 (GH-99017)

serhiy-storchaka webhook-mailer at python.org
Wed Nov 2 14:30:27 EDT 2022


https://github.com/python/cpython/commit/f520d720f667c87f7b70ed86ea58d73892d6b969
commit: f520d720f667c87f7b70ed86ea58d73892d6b969
branch: main
author: Serhiy Storchaka <storchaka at gmail.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2022-11-02T20:30:09+02:00
summary:

gh-99016: Make build scripts compatible with Python 3.8 (GH-99017)

files:
A Misc/NEWS.d/next/Build/2022-11-02-19-25-07.gh-issue-99016.R05NkD.rst
M Tools/build/generate_levenshtein_examples.py
M Tools/build/generate_opcode_h.py

diff --git a/Misc/NEWS.d/next/Build/2022-11-02-19-25-07.gh-issue-99016.R05NkD.rst b/Misc/NEWS.d/next/Build/2022-11-02-19-25-07.gh-issue-99016.R05NkD.rst
new file mode 100644
index 000000000000..df189daca3a2
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-11-02-19-25-07.gh-issue-99016.R05NkD.rst
@@ -0,0 +1 @@
+Fix build with ``PYTHON_FOR_REGEN=python3.8``.
diff --git a/Tools/build/generate_levenshtein_examples.py b/Tools/build/generate_levenshtein_examples.py
index 5a8360fff731..778eb458c541 100644
--- a/Tools/build/generate_levenshtein_examples.py
+++ b/Tools/build/generate_levenshtein_examples.py
@@ -1,7 +1,7 @@
 """Generate 10,000 unique examples for the Levenshtein short-circuit tests."""
 
 import argparse
-from functools import cache
+from functools import lru_cache
 import json
 import os.path
 from random import choices, randrange
@@ -22,7 +22,7 @@ def _substitution_cost(ch_a, ch_b):
     return _MOVE_COST
 
 
- at cache
+ at lru_cache(None)
 def levenshtein(a, b):
     if not a or not b:
         return (len(a) + len(b)) * _MOVE_COST
diff --git a/Tools/build/generate_opcode_h.py b/Tools/build/generate_opcode_h.py
index 372221a14d07..174573a3c64b 100644
--- a/Tools/build/generate_opcode_h.py
+++ b/Tools/build/generate_opcode_h.py
@@ -108,7 +108,7 @@ def main(opcode_py, outfile='Include/opcode.h', internaloutfile='Include/interna
     opname_including_specialized[255] = 'DO_TRACING'
     used[255] = True
 
-    with (open(outfile, 'w') as fobj, open(internaloutfile, 'w') as iobj):
+    with open(outfile, 'w') as fobj, open(internaloutfile, 'w') as iobj:
         fobj.write(header)
         iobj.write(internal_header)
 



More information about the Python-checkins mailing list