Skip to content

Commit 9c239fb

Browse files
authored
gh-159739: Preserve the syntax error if metadata allocation fails (#159751)
Restore the original exception when optional syntax-error metadata cannot be allocated.
1 parent 626394e commit 9c239fb

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Preserve the original :exc:`SyntaxError` if allocating optional error metadata
2+
fails.

‎Parser/pegen.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ _PyPegen_set_syntax_error_metadata(Parser *p) {
10831083
);
10841084
if (!metadata) {
10851085
PyErr_Clear();
1086+
PyErr_SetRaisedException(exc);
10861087
return;
10871088
}
10881089
PySyntaxErrorObject *syntax_error = (PySyntaxErrorObject *)exc;

0 commit comments

Comments
 (0)