summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-05-11 00:41:26 (GMT)
committerGitHub <noreply@github.com>2020-05-11 00:41:26 (GMT)
commit5b956ca42de37c761562e9c9aeb96a0e67606e33 (patch)
tree5f7ce29546bf89d847ae222a91acc924af84c949 /Parser
parent2cc9b8486dd924214f9e5657672fdeb24449d206 (diff)
downloadcpython-5b956ca42de37c761562e9c9aeb96a0e67606e33.zip
cpython-5b956ca42de37c761562e9c9aeb96a0e67606e33.tar.gz
cpython-5b956ca42de37c761562e9c9aeb96a0e67606e33.tar.bz2
bpo-40585: Normalize errors messages in codeop when comparing them (GH-20030)
With the new parser, the error message contains always the trailing newlines, causing the comparison of the repr of the error messages in codeop to fail. This commit makes the new parser mirror the old parser's behaviour regarding trailing newlines.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/pegen.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index 06af53b..c80f086 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -310,6 +310,12 @@ get_error_line(char *buffer, int is_file)
newline = strchr(buffer, '\n');
}
+ if (is_file) {
+ while (newline > buffer && newline[-1] == '\n') {
+ --newline;
+ }
+ }
+
if (newline) {
return PyUnicode_DecodeUTF8(buffer, newline - buffer, "replace");
}