➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 lys.nikolaou
收信人 christian.heimes, lys.nikolaou, pablogsal
日期 2020-06-12.16:01:55
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1591977715.95.0.533686553983.issue40958@roundup.psfhosted.org>
In-reply-to
内容
I'm guessing that some parts of the conversion code were only there to circumvent issues in displaying the error messages that weren't pegen's fault. These were fixed by Guido in GH-20072, so I think we can delete some of them. For example, this patch works just fine for me.

diff --git a/Parser/pegen.c b/Parser/pegen.c
index e29910bf86..2c348178fb 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -150,10 +150,6 @@ byte_offset_to_character_offset(PyObject *line, int col_offset)
         return 0;
     }
     Py_ssize_t size = PyUnicode_GET_LENGTH(text);
-    str = PyUnicode_AsUTF8(text);
-    if (str != NULL && (int)strlen(str) == col_offset) {
-        size = strlen(str);
-    }
     Py_DECREF(text);
     return size;
 }
@@ -400,9 +396,6 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,

     if (!error_line) {
         Py_ssize_t size = p->tok->inp - p->tok->buf;
-        if (size && p->tok->buf[size-1] == '\n') {
-            size--;
-        }
         error_line = PyUnicode_DecodeUTF8(p->tok->buf, size, "replace");
         if (!error_line) {
             goto error;
历史
日期 用户 动作 参数
2020-06-12 16:01:55lys.nikolaou修改recipients: + lys.nikolaou, christian.heimes, pablogsal
2020-06-12 16:01:55lys.nikolaou修改messageid: <1591977715.95.0.533686553983.issue40958@roundup.psfhosted.org>
2020-06-12 16:01:55lys.nikolaou链接issue40958 messages
2020-06-12 16:01:55lys.nikolaou创建