gh-98831: Modernize FORMAT_VALUE (#101628)

Generator update: support balanced parentheses and brackets in conditions and size expressions.
This commit is contained in:
Guido van Rossum 2023-02-07 17:35:55 -08:00 committed by GitHub
parent aacbdb0c65
commit b2b85b5db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 35 deletions

View file

@ -333,7 +333,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
case BUILD_SLICE:
return ((oparg == 3) ? 1 : 0) + 2;
case FORMAT_VALUE:
return -1;
return (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0) + 1;
case COPY:
return (oparg-1) + 1;
case BINARY_OP:
@ -681,7 +681,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
case BUILD_SLICE:
return 1;
case FORMAT_VALUE:
return -1;
return 1;
case COPY:
return (oparg-1) + 2;
case BINARY_OP: