Skip to content

Commit eb3c94e

Browse files
authored
gh-110319: Assert type_version != 0 before using it (#112226)
- Ensure that `assert(type_version != 0);` always comes *before* using `type_version` Also: - In cases_generator, rename `-v` to from `--verbose` to `--viable`
1 parent 43b1c33 commit eb3c94e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,8 +2026,8 @@ dummy_func(
20262026
DEOPT_IF(tstate->interp->eval_frame);
20272027

20282028
PyTypeObject *cls = Py_TYPE(owner);
2029-
DEOPT_IF(cls->tp_version_tag != type_version);
20302029
assert(type_version != 0);
2030+
DEOPT_IF(cls->tp_version_tag != type_version);
20312031
assert(Py_IS_TYPE(fget, &PyFunction_Type));
20322032
PyFunctionObject *f = (PyFunctionObject *)fget;
20332033
assert(func_version != 0);
@@ -2049,8 +2049,8 @@ dummy_func(
20492049
assert((oparg & 1) == 0);
20502050
DEOPT_IF(tstate->interp->eval_frame);
20512051
PyTypeObject *cls = Py_TYPE(owner);
2052-
DEOPT_IF(cls->tp_version_tag != type_version);
20532052
assert(type_version != 0);
2053+
DEOPT_IF(cls->tp_version_tag != type_version);
20542054
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
20552055
PyFunctionObject *f = (PyFunctionObject *)getattribute;
20562056
assert(func_version != 0);

Python/generated_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/generate_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
arg_parser.add_argument(
9696
"-v",
97-
"--verbose",
97+
"--viable",
9898
help="Print list of non-viable uops and exit",
9999
action="store_true",
100100
)
@@ -871,7 +871,7 @@ def main() -> None:
871871
a.analyze() # Prints messages and sets a.errors on failure
872872
if a.errors:
873873
sys.exit(f"Found {a.errors} errors")
874-
if args.verbose:
874+
if args.viable:
875875
# Load execution counts from bmraw.json, if it exists
876876
a.report_non_viable_uops("bmraw.json")
877877
return

0 commit comments

Comments
 (0)