Skip to content

Commit 3f9c57e

Browse files
committed
address review: revert _PyTokenizer_From* changes
1 parent 9ea138f commit 3f9c57e

5 files changed

Lines changed: 12 additions & 16 deletions

File tree

Parser/pegen.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,8 +1055,7 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena
10551055
PyObject **interactive_src, PyArena *arena)
10561056
{
10571057
int parser_flags = compute_parser_flags(flags);
1058-
struct tok_state *tok = _PyTokenizer_FromFile(fp, enc, ps1, ps2,
1059-
parser_flags & PyPARSE_BARRY_AS_BDFL);
1058+
struct tok_state *tok = _PyTokenizer_FromFile(fp, enc, ps1, ps2);
10601059
if (tok == NULL) {
10611060
if (PyErr_Occurred()) {
10621061
_PyTokenizer_raise_init_error(filename_ob);
@@ -1067,6 +1066,7 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena
10671066
}
10681067
return NULL;
10691068
}
1069+
tok->barry_as_bdfl = parser_flags & PyPARSE_BARRY_AS_BDFL;
10701070
if (!tok->fp || ps1 != NULL || ps2 != NULL ||
10711071
PyUnicode_CompareWithASCIIString(filename_ob, "<stdin>") == 0) {
10721072
tok->fp_interactive = 1;
@@ -1114,9 +1114,9 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen
11141114

11151115
struct tok_state *tok;
11161116
if (flags != NULL && flags->cf_flags & PyCF_IGNORE_COOKIE) {
1117-
tok = _PyTokenizer_FromUTF8(str, exec_input, 0, parser_flags & PyPARSE_BARRY_AS_BDFL);
1117+
tok = _PyTokenizer_FromUTF8(str, exec_input, 0);
11181118
} else {
1119-
tok = _PyTokenizer_FromString(str, exec_input, 0, parser_flags & PyPARSE_BARRY_AS_BDFL);
1119+
tok = _PyTokenizer_FromString(str, exec_input, 0);
11201120
}
11211121
if (tok == NULL) {
11221122
if (PyErr_Occurred()) {
@@ -1128,6 +1128,7 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen
11281128
}
11291129
return NULL;
11301130
}
1131+
tok->barry_as_bdfl = parser_flags & PyPARSE_BARRY_AS_BDFL;
11311132
// This transfers the ownership to the tokenizer
11321133
tok->filename = Py_NewRef(filename_ob);
11331134
tok->module = Py_XNewRef(module);

Parser/tokenizer/file_tokenizer.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ tok_underflow_file(struct tok_state *tok)
371371
/* Set up tokenizer for file */
372372
struct tok_state *
373373
_PyTokenizer_FromFile(FILE *fp, const char* enc,
374-
const char *ps1, const char *ps2,
375-
int barry_as_bdfl)
374+
const char *ps1, const char *ps2)
376375
{
377376
struct tok_state *tok = _PyTokenizer_tok_new();
378377
if (tok == NULL)
@@ -402,7 +401,6 @@ _PyTokenizer_FromFile(FILE *fp, const char* enc,
402401
}
403402
tok->decoding_state = STATE_NORMAL;
404403
}
405-
tok->barry_as_bdfl = barry_as_bdfl;
406404
return tok;
407405
}
408406

@@ -459,7 +457,7 @@ _PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
459457
if (fp == NULL) {
460458
return NULL;
461459
}
462-
tok = _PyTokenizer_FromFile(fp, NULL, NULL, NULL, 0);
460+
tok = _PyTokenizer_FromFile(fp, NULL, NULL, NULL);
463461
if (tok == NULL) {
464462
fclose(fp);
465463
return NULL;

Parser/tokenizer/string_tokenizer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ decode_str(const char *input, int single, struct tok_state *tok, int preserve_cr
128128

129129
/* Set up tokenizer for string */
130130
struct tok_state *
131-
_PyTokenizer_FromString(const char *str, int exec_input, int preserve_crlf, int barry_as_bdfl)
131+
_PyTokenizer_FromString(const char *str, int exec_input, int preserve_crlf)
132132
{
133133
struct tok_state *tok = _PyTokenizer_tok_new();
134134
char *decoded;
@@ -144,6 +144,5 @@ _PyTokenizer_FromString(const char *str, int exec_input, int preserve_crlf, int
144144
tok->buf = tok->cur = tok->inp = decoded;
145145
tok->end = decoded;
146146
tok->underflow = &tok_underflow_string;
147-
tok->barry_as_bdfl = barry_as_bdfl;
148147
return tok;
149148
}

Parser/tokenizer/tokenizer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
#include "Python.h"
55

6-
struct tok_state *_PyTokenizer_FromString(const char *, int, int, int);
7-
struct tok_state *_PyTokenizer_FromUTF8(const char *, int, int, int);
6+
struct tok_state *_PyTokenizer_FromString(const char *, int, int);
7+
struct tok_state *_PyTokenizer_FromUTF8(const char *, int, int);
88
struct tok_state *_PyTokenizer_FromReadline(PyObject*, const char*, int, int);
99
struct tok_state *_PyTokenizer_FromFile(FILE *, const char*,
10-
const char *, const char *, int);
10+
const char *, const char *);
1111

1212
#define tok_dump _Py_tok_dump
1313

Parser/tokenizer/utf8_tokenizer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ tok_underflow_string(struct tok_state *tok) {
2828

2929
/* Set up tokenizer for UTF-8 string */
3030
struct tok_state *
31-
_PyTokenizer_FromUTF8(const char *str, int exec_input, int preserve_crlf,
32-
int barry_as_bdfl)
31+
_PyTokenizer_FromUTF8(const char *str, int exec_input, int preserve_crlf)
3332
{
3433
struct tok_state *tok = _PyTokenizer_tok_new();
3534
char *translated;
@@ -52,6 +51,5 @@ _PyTokenizer_FromUTF8(const char *str, int exec_input, int preserve_crlf,
5251
tok->buf = tok->cur = tok->inp = translated;
5352
tok->end = translated;
5453
tok->underflow = &tok_underflow_string;
55-
tok->barry_as_bdfl = barry_as_bdfl;
5654
return tok;
5755
}

0 commit comments

Comments
 (0)