diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-04-12 15:59:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 15:59:30 (GMT) |
commit | b86ed8e3bb41ede77eeab4a8bb4e2b91a8065283 (patch) | |
tree | 250e32e95a6bead87006d2e1e1a06d9058fc3b91 /Parser/pegen.c | |
parent | 2459b92a4db69d9b14d0a86a9b81cc075894e910 (diff) | |
download | cpython-b86ed8e3bb41ede77eeab4a8bb4e2b91a8065283.zip cpython-b86ed8e3bb41ede77eeab4a8bb4e2b91a8065283.tar.gz cpython-b86ed8e3bb41ede77eeab4a8bb4e2b91a8065283.tar.bz2 |
bpo-43797: Improve syntax error for invalid comparisons (#25317)
* bpo-43797: Improve syntax error for invalid comparisons
* Update Lib/test/test_fstring.py
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* Apply review comments
* can't -> cannot
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r-- | Parser/pegen.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index f841ace..7258caf 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -147,8 +147,8 @@ byte_offset_to_character_offset(PyObject *line, Py_ssize_t col_offset) return 0; } Py_ssize_t len = strlen(str); - if (col_offset > len) { - col_offset = len; + if (col_offset > len + 1) { + col_offset = len + 1; } assert(col_offset >= 0); PyObject *text = PyUnicode_DecodeUTF8(str, col_offset, "replace"); @@ -184,7 +184,7 @@ _PyPegen_get_expr_name(expr_ty e) case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: - return "operator"; + return "expression"; case GeneratorExp_kind: return "generator expression"; case Yield_kind: @@ -199,7 +199,7 @@ _PyPegen_get_expr_name(expr_ty e) case DictComp_kind: return "dict comprehension"; case Dict_kind: - return "dict display"; + return "dict literal"; case Set_kind: return "set display"; case JoinedStr_kind: |