Kaydet (Commit) 83ab9958 authored tarafından Stéphane Wirtel's avatar Stéphane Wirtel Kaydeden (comit) Christian Heimes

bpo-32711: Fix warnings for Python/ast_unparse.c (#5426)

* bpo-32711: Fix warnings for Python/ast_unparse.c
üst 97f1ca16
Fix the warning messages for Python/ast_unparse.c. Patch by Stéphane Wirtel
...@@ -20,7 +20,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec); ...@@ -20,7 +20,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec);
static int static int
append_charp(_PyUnicodeWriter *writer, const char *charp) append_charp(_PyUnicodeWriter *writer, const char *charp)
{ {
return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1); return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);
} }
static int static int
...@@ -100,6 +100,8 @@ append_ast_binop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens) ...@@ -100,6 +100,8 @@ append_ast_binop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
case BitAnd: op = " & "; break; case BitAnd: op = " & "; break;
case FloorDiv: op = " // "; break; case FloorDiv: op = " // "; break;
case Pow: op = " ** "; break; case Pow: op = " ** "; break;
default:
Py_UNREACHABLE();
} }
if (-1 == append_charp(writer, op)) { if (-1 == append_charp(writer, op)) {
...@@ -127,6 +129,8 @@ append_ast_unaryop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens) ...@@ -127,6 +129,8 @@ append_ast_unaryop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
case Not: op = "not "; break; case Not: op = "not "; break;
case UAdd: op = "+"; break; case UAdd: op = "+"; break;
case USub: op = "-"; break; case USub: op = "-"; break;
default:
Py_UNREACHABLE();
} }
if (-1 == append_charp(writer, op)) { if (-1 == append_charp(writer, op)) {
...@@ -856,7 +860,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec) ...@@ -856,7 +860,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec)
return -1; return -1;
} }
} }
if (e->v.FormattedValue.format_spec > 0) { if (e->v.FormattedValue.format_spec) {
if (-1 == _PyUnicodeWriter_WriteASCIIString(writer, ":", 1) || if (-1 == _PyUnicodeWriter_WriteASCIIString(writer, ":", 1) ||
-1 == append_fstring_element(writer, -1 == append_fstring_element(writer,
e->v.FormattedValue.format_spec, e->v.FormattedValue.format_spec,
...@@ -1119,7 +1123,7 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens) ...@@ -1119,7 +1123,7 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
} }
static int static int
maybe_init_static_strings() maybe_init_static_strings(void)
{ {
if (!_str_open_br && if (!_str_open_br &&
!(_str_open_br = PyUnicode_InternFromString("{"))) { !(_str_open_br = PyUnicode_InternFromString("{"))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment