Skip to content

Commit 5e9a658

Browse files
committed
Simplify
1 parent 4e04e6a commit 5e9a658

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Parser/pegen.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
851851
p->last_stmt_location.col_offset = 0;
852852
p->last_stmt_location.end_lineno = 0;
853853
p->last_stmt_location.end_col_offset = 0;
854-
p->source = source;
855854
#ifdef Py_DEBUG
856855
p->debug = _Py_GetConfig()->parser_debug;
857856
#endif
@@ -900,8 +899,11 @@ _PyPegen_set_syntax_error_metadata(Parser *p) {
900899
PyErr_SetRaisedException(exc);
901900
return;
902901
}
903-
const char *source = p->source;
904-
if (!p->source && p->tok->fp_interactive && p->tok->interactive_src_start) {
902+
const char *source = NULL;
903+
if (p->tok->str != NULL) {
904+
source = p->tok->str;
905+
}
906+
if (!source && p->tok->fp_interactive && p->tok->interactive_src_start) {
905907
source = p->tok->interactive_src_start;
906908
}
907909
PyObject* the_source = NULL;

Parser/pegen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ typedef struct {
8686
int call_invalid_rules;
8787
int debug;
8888
location last_stmt_location;
89-
const char *source;
9089
} Parser;
9190

9291
typedef struct {

0 commit comments

Comments
 (0)