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

gh-102856: Clean some of the PEP 701 tokenizer implementation #103634

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 2 commits into from
Apr 19, 2023
Merged
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
fixup! gh-102856: Clean some of the PEP 701 tokenizer implementation
  • Loading branch information
pablogsal committed Apr 19, 2023
commit a377562ba73894ee1e851f52ef0240fd7b348494
5 changes: 3 additions & 2 deletions 5 Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
tok->col_offset = 0;

#define INSIDE_FSTRING(tok) (tok->tok_mode_stack_index > 0)
#define INSIDE_FSTRING_EXPR(tok) (tok->curly_bracket_expr_start_depth >= 0)
#ifdef Py_DEBUG
static inline tokenizer_mode* TOK_GET_MODE(struct tok_state* tok) {
assert(tok->tok_mode_stack_index >= 0);
Expand Down Expand Up @@ -2330,7 +2331,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t

/* Punctuation character */
int is_punctuation = (c == ':' || c == '}' || c == '!' || c == '{');
if (is_punctuation && INSIDE_FSTRING(tok) && current_tok->curly_bracket_expr_start_depth >= 0) {
if (is_punctuation && INSIDE_FSTRING(tok) && INSIDE_FSTRING_EXPR(current_tok)) {
/* This code block gets executed before the curly_bracket_depth is incremented
* by the `{` case, so for ensuring that we are on the 0th level, we need
* to adjust it manually */
Expand Down Expand Up @@ -2537,7 +2538,7 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
int in_format_spec = (
current_tok->last_expr_end != -1
&&
current_tok->curly_bracket_expr_start_depth >= 0
INSIDE_FSTRING_EXPR(current_tok)
);
if (c == '{') {
int peek = tok_nextc(tok);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.