Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.11] gh-112387: Fix error positions for decoded strings with backwards tokenize errors (GH-112409)#112469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-112387: Fix error positions for decoded strings with backwards tok…
…enize errors (GH-112409)(cherry picked from commit45d6485)Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
@pablogsal@miss-islington
pablogsal authored andmiss-islington committedNov 27, 2023
commit07e457ff71cb95c1894616ff051b77633920f456
4 changes: 4 additions & 0 deletionsLib/test/test_syntax.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2143,6 +2143,10 @@ def test_error_parenthesis(self):
"""
self._check_error(code, "parenthesis '\\)' does not match opening parenthesis '\\['")

# Examples with dencodings
s = b'# coding=latin\n(aaaaaaaaaaaaaaaaa\naaaaaaaaaaa\xb5'
self._check_error(s, "'\(' was never closed")

def test_error_string_literal(self):

self._check_error("'blech", "unterminated string literal")
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Fix error positions for decoded strings with backwards tokenize errors.
Patch by Pablo Galindo
4 changes: 4 additions & 0 deletionsParser/pegen_errors.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,6 +266,10 @@ get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno)
Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno;
const char* buf_end = p->tok->fp_interactive ? p->tok->interactive_src_end : p->tok->inp;

if (buf_end < cur_line) {
buf_end = cur_line + strlen(cur_line);
}

for (int i = 0; i < relative_lineno - 1; i++) {
char *new_line = strchr(cur_line, '\n');
// The assert is here for debug builds but the conditional that
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp