Skip to content
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

Allow NUL character in f-strings #7378

Merged
merged 1 commit into from Sep 14, 2023
Merged

Conversation

dhruvmanila
Copy link
Member

Summary

This PR fixes the bug to allow NUL (\0) character inside f-strings.

Test Plan

Add test case with NUL character inside f-string.

Comment on lines +555 to +558
// The condition is to differentiate between the `NUL` (`\0`) character
// in the source code and the one returned by `self.cursor.first()` when
// we reach the end of the source code.
EOF_CHAR if self.cursor.is_eof() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move this in the catch-all branch but that would mean that the check will be performed for almost every character.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah. That's why using self.cursor.first() is "dangerous" and I prefer to use bump wherever I can. Can you do a quick double check if any other code needs to check for self.cursor.is_eof()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's the only place where it seems necessary.

@dhruvmanila dhruvmanila added parser Related to the parser python312 Related to Python 3.12 labels Sep 14, 2023
Comment on lines +555 to +558
// The condition is to differentiate between the `NUL` (`\0`) character
// in the source code and the one returned by `self.cursor.first()` when
// we reach the end of the source code.
EOF_CHAR if self.cursor.is_eof() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah. That's why using self.cursor.first() is "dangerous" and I prefer to use bump wherever I can. Can you do a quick double check if any other code needs to check for self.cursor.is_eof()

@dhruvmanila dhruvmanila merged commit 5d0063a into dhruv/pep-701 Sep 14, 2023
12 of 16 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/fstring-nul branch September 14, 2023 10:58
@dhruvmanila dhruvmanila linked an issue Sep 15, 2023 that may be closed by this pull request
dhruvmanila added a commit that referenced this pull request Sep 18, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 19, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 20, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 22, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 22, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 22, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 26, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 27, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 28, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 29, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
dhruvmanila added a commit that referenced this pull request Sep 29, 2023
## Summary

This PR fixes the bug to allow `NUL` (`\0`) character inside f-strings.

## Test Plan

Add test case with `NUL` character inside f-string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Related to the parser python312 Related to Python 3.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for PEP 701 in the lexer
2 participants