Skip to content

Commit 1a53ccd

Browse files
committed
Minor comments and variable renaming.
1 parent dba7421 commit 1a53ccd

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Lib/test/test_fstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ def __repr__(self):
11511151
def test_walrus(self):
11521152
x = 20
11531153
# This isn't an assignment expression, it's 'x', with a format
1154-
# spec of '=10'. See test_walrus: you need to use parens.
1154+
# spec of '=10'.
11551155
self.assertEqual(f'{x:=10}', ' 20')
11561156

11571157
# This is an assignment expression, which requires parens.

Python/ast.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5020,7 +5020,7 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
50205020
int conversion = -1; /* The conversion char. Use default if not
50215021
specified, or !r if using = and no format
50225022
spec. */
5023-
int equal_conversion = 0; /* Are we using the = feature? */
5023+
int equal_flag = 0; /* Are we using the = feature? */
50245024
PyObject *expr_text = NULL; /* The text of the expression, used for =. */
50255025
const char *expr_text_end;
50265026

@@ -5198,10 +5198,11 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
51985198
expr_text. */
51995199
if (**str == '=') {
52005200
*str += 1;
5201-
equal_conversion = 1;
5201+
equal_flag = 1;
52025202

52035203
/* Skip over ASCII whitespace. No need to test for end of string
5204-
here, since we know there's at least a } somewhere ahead. */
5204+
here, since we know there's at least a trailing quote somewhere
5205+
ahead. */
52055206
while (Py_ISSPACE(**str)) {
52065207
*str += 1;
52075208
}
@@ -5226,7 +5227,7 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
52265227
}
52275228

52285229
}
5229-
if (equal_conversion) {
5230+
if (equal_flag) {
52305231
Py_ssize_t len = expr_text_end-expr_start;
52315232
expr_text = PyUnicode_FromStringAndSize(expr_start, len);
52325233
if (!expr_text)
@@ -5257,7 +5258,7 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
52575258

52585259
/* If we're in = mode, and have no format spec and no explict conversion,
52595260
set the conversion to 'r'. */
5260-
if (equal_conversion && format_spec == NULL && conversion == -1) {
5261+
if (equal_flag && format_spec == NULL && conversion == -1) {
52615262
conversion = 'r';
52625263
}
52635264

Python/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3947,7 +3947,7 @@ compiler_formatted_value(struct compiler *c, expr_ty e)
39473947
character, and whether or not a format_spec was provided.
39483948
39493949
Convert the conversion char to 3 bits:
3950-
!f : 000 0x0 FVC_NONE The default if nothing specified.
3950+
: 000 0x0 FVC_NONE The default if nothing specified.
39513951
!s : 001 0x1 FVC_STR
39523952
!r : 010 0x2 FVC_REPR
39533953
!a : 011 0x3 FVC_ASCII

0 commit comments

Comments
 (0)