diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2021-04-29 05:58:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 05:58:44 (GMT) |
commit | 1e7b858575d0ad782939f86aae4a2fa1c29e9f14 (patch) | |
tree | 9445a7a82905c5bb253564853f33dacfceac6e93 /Python/ast_unparse.c | |
parent | e52ab42cedd2a5ef4c3c1a47d0cf96a8f06d051f (diff) | |
download | cpython-1e7b858575d0ad782939f86aae4a2fa1c29e9f14.zip cpython-1e7b858575d0ad782939f86aae4a2fa1c29e9f14.tar.gz cpython-1e7b858575d0ad782939f86aae4a2fa1c29e9f14.tar.bz2 |
bpo-43892: Make match patterns explicit in the AST (GH-25585)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Diffstat (limited to 'Python/ast_unparse.c')
-rw-r--r-- | Python/ast_unparse.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c index 5276b2f..126e904 100644 --- a/Python/ast_unparse.c +++ b/Python/ast_unparse.c @@ -3,6 +3,11 @@ #include <float.h> // DBL_MAX_10_EXP #include <stdbool.h> +/* This limited unparser is used to convert annotations back to strings + * during compilation rather than being a full AST unparser. + * See ast.unparse for a full unparser (written in Python) + */ + static PyObject *_str_open_br; static PyObject *_str_dbl_open_br; static PyObject *_str_close_br; @@ -912,11 +917,11 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level) return append_ast_tuple(writer, e, level); case NamedExpr_kind: return append_named_expr(writer, e, level); - default: - PyErr_SetString(PyExc_SystemError, - "unknown expression kind"); - return -1; + // No default so compiler emits a warning for unhandled cases } + PyErr_SetString(PyExc_SystemError, + "unknown expression kind"); + return -1; } static int |