Skip to content

Commit 83ab995

Browse files
matrixisetiran
authored andcommitted
bpo-32711: Fix warnings for Python/ast_unparse.c (#5426)
* bpo-32711: Fix warnings for Python/ast_unparse.c
1 parent 97f1ca1 commit 83ab995

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the warning messages for Python/ast_unparse.c. Patch by Stéphane Wirtel

Python/ast_unparse.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec);
2020
static int
2121
append_charp(_PyUnicodeWriter *writer, const char *charp)
2222
{
23-
return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);
23+
return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);
2424
}
2525

2626
static int
@@ -100,6 +100,8 @@ append_ast_binop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
100100
case BitAnd: op = " & "; break;
101101
case FloorDiv: op = " // "; break;
102102
case Pow: op = " ** "; break;
103+
default:
104+
Py_UNREACHABLE();
103105
}
104106

105107
if (-1 == append_charp(writer, op)) {
@@ -127,6 +129,8 @@ append_ast_unaryop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
127129
case Not: op = "not "; break;
128130
case UAdd: op = "+"; break;
129131
case USub: op = "-"; break;
132+
default:
133+
Py_UNREACHABLE();
130134
}
131135

132136
if (-1 == append_charp(writer, op)) {
@@ -856,7 +860,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec)
856860
return -1;
857861
}
858862
}
859-
if (e->v.FormattedValue.format_spec > 0) {
863+
if (e->v.FormattedValue.format_spec) {
860864
if (-1 == _PyUnicodeWriter_WriteASCIIString(writer, ":", 1) ||
861865
-1 == append_fstring_element(writer,
862866
e->v.FormattedValue.format_spec,
@@ -1119,7 +1123,7 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
11191123
}
11201124

11211125
static int
1122-
maybe_init_static_strings()
1126+
maybe_init_static_strings(void)
11231127
{
11241128
if (!_str_open_br &&
11251129
!(_str_open_br = PyUnicode_InternFromString("{"))) {

0 commit comments

Comments
 (0)