[Python-checkins] GH-99104: Update headers for bytecodes.c and generate_cases.py (#99112)

gvanrossum webhook-mailer at python.org
Fri Nov 4 20:40:49 EDT 2022


https://github.com/python/cpython/commit/d04899abb0da4cc7c0a390f5bc52d57ace8955fd
commit: d04899abb0da4cc7c0a390f5bc52d57ace8955fd
branch: main
author: Guido van Rossum <guido at python.org>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2022-11-04T17:40:43-07:00
summary:

GH-99104: Update headers for bytecodes.c and generate_cases.py (#99112)

Also tweak the labels near the end of bytecodes.c.

files:
M Python/bytecodes.c
M Python/generated_cases.c.h
M Tools/cases_generator/generate_cases.py

diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 16ac1d9d2e95..e87ca6ebe8a0 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -1,3 +1,11 @@
+// This file contains instruction definitions.
+// It is read by Tools/cases_generator/generate_cases.py
+// to generate Python/generated_cases.c.h.
+// Note that there is some dummy C code at the top and bottom of the file
+// to fool text editors like VS Code into believing this is valid C code.
+// The actual instruction definitions start at // BEGIN BYTECODES //.
+// See Tools/cases_generator/README.md for more information.
+
 #include "Python.h"
 #include "pycore_abstract.h"      // _PyIndex_Check()
 #include "pycore_call.h"          // _PyObject_FastCallDictTstate()
@@ -4003,13 +4011,14 @@ dummy_func(
 // END BYTECODES //
 
     }
- error:;
- exception_unwind:;
- handle_eval_breaker:;
- resume_frame:;
- resume_with_error:;
- start_frame:;
- unbound_local_error:;
+ error:
+ exception_unwind:
+ handle_eval_breaker:
+ resume_frame:
+ resume_with_error:
+ start_frame:
+ unbound_local_error:
+    ;
 }
 
 // Families go below this point //
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index bea51d7e5160..c678de5dff33 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -1,4 +1,4 @@
-// This file is generated by Tools/scripts/generate_cases.py
+// This file is generated by Tools/cases_generator/generate_cases.py
 // Do not edit!
 
         TARGET(NOP) {
diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py
index 82e58017d648..ec2481b31b9f 100644
--- a/Tools/cases_generator/generate_cases.py
+++ b/Tools/cases_generator/generate_cases.py
@@ -6,6 +6,7 @@
 
 import argparse
 import io
+import os
 import re
 import sys
 
@@ -67,7 +68,7 @@ def write_cases(f: io.TextIOBase, instrs: list[InstDef]):
         for target in re.findall(r"(?:PREDICT|GO_TO_INSTRUCTION)\((\w+)\)", inst.block.text):
             predictions.add(target)
     indent = "        "
-    f.write("// This file is generated by Tools/scripts/generate_cases.py\n")
+    f.write(f"// This file is generated by {os.path.relpath(__file__)}\n")
     f.write("// Do not edit!\n")
     for instr in instrs:
         assert isinstance(instr, InstDef)



More information about the Python-checkins mailing list