]> granicus.if.org Git - python/commitdiff
[3.7] bpo-32711: Fix warnings for Python/ast_unparse.c (GH-5426) (#5475)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 1 Feb 2018 17:41:24 +0000 (09:41 -0800)
committerChristian Heimes <christian@python.org>
Thu, 1 Feb 2018 17:41:24 +0000 (18:41 +0100)
* bpo-32711: Fix warnings for Python/ast_unparse.c
(cherry picked from commit 83ab995871ffd504ac229bdbf5b9e9ffc1032815)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
Misc/NEWS.d/next/Core and Builtins/2018-01-29-14-36-37.bpo-32711.8hQFJP.rst [new file with mode: 0644]
Python/ast_unparse.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-01-29-14-36-37.bpo-32711.8hQFJP.rst b/Misc/NEWS.d/next/Core and Builtins/2018-01-29-14-36-37.bpo-32711.8hQFJP.rst
new file mode 100644 (file)
index 0000000..4d55b89
--- /dev/null
@@ -0,0 +1 @@
+Fix the warning messages for Python/ast_unparse.c. Patch by Stéphane Wirtel
index ef9e948dc8254ce3f6e3d5f66f7d9f08bce97bcd..1345271e599b5c465a25e3a10a849f8942d679ec 100644 (file)
@@ -20,7 +20,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec);
 static int
 append_charp(_PyUnicodeWriter *writer, const char *charp)
 {
-        return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);
+    return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);
 }
 
 static int
@@ -100,6 +100,8 @@ append_ast_binop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
     case BitAnd: op = " & "; break;
     case FloorDiv: op = " // "; break;
     case Pow: op = " ** "; break;
+    default:
+        Py_UNREACHABLE();
     }
 
     if (-1 == append_charp(writer, op)) {
@@ -127,6 +129,8 @@ append_ast_unaryop(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
     case Not: op = "not "; break;
     case UAdd: op = "+"; break;
     case USub: op = "-"; break;
+    default:
+        Py_UNREACHABLE();
     }
 
     if (-1 == append_charp(writer, op)) {
@@ -856,7 +860,7 @@ append_formattedvalue(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec)
             return -1;
         }
     }
-    if (e->v.FormattedValue.format_spec > 0) {
+    if (e->v.FormattedValue.format_spec) {
         if (-1 == _PyUnicodeWriter_WriteASCIIString(writer, ":", 1) ||
             -1 == append_fstring_element(writer,
                                          e->v.FormattedValue.format_spec,
@@ -1119,7 +1123,7 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, bool omit_parens)
 }
 
 static int
-maybe_init_static_strings()
+maybe_init_static_strings(void)
 {
     if (!_str_open_br &&
         !(_str_open_br = PyUnicode_InternFromString("{"))) {