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

Appearance settings

bpo-40585: Normalize errors messages in codeop when comparing them #20030

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup! bpo-40585: Normalize errors messages in codeop when comparing …
…them
  • Loading branch information
pablogsal committed May 10, 2020
commit 5990c710d78a85203af68740868da64d27032445
5 changes: 1 addition & 4 deletions 5 Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ def _maybe_compile(compiler, source, filename, symbol):
except SyntaxError as e:
err2 = e

def normalize_error(err):
return repr(err).replace("\\n", "")

try:
if code:
return code
if not code1 and normalize_error(err1) == normalize_error(err2):
if not code1 and repr(err1) == repr(err2):
raise err1
finally:
err1 = err2 = None
Expand Down
6 changes: 5 additions & 1 deletion 6 Parser/pegen/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ get_error_line(char *buffer, int is_file)
newline = strchr(buffer, '\n');
}

while (newline && *newline == '\n') {
newline -= 1;
}

if (newline) {
return PyUnicode_DecodeUTF8(buffer, newline - buffer, "replace");
return PyUnicode_DecodeUTF8(buffer, newline - buffer + 1, "replace");
pablogsal marked this conversation as resolved.
Show resolved Hide resolved
}
else {
return PyUnicode_DecodeUTF8(buffer, strlen(buffer), "replace");
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.