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

Fix parsing of code without trailing newlines #940

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

zsol
Copy link
Member

@zsol zsol commented May 28, 2023

When the input doesn't have a trailing newline, but the last line had
exactly the amount of bytes as the current indentation level, the
tokenizer didn't emit a fake newline, causing parse errors (the grammar
expects newlines to conform with the Python spec).

I don't see any reason for fake newlines to be omitted in these cases,
so this PR removes that condition from the tokenizer.

Reported in #930.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 28, 2023
@zsol zsol force-pushed the native/fake-newline-when-bol branch from 4c0bec2 to 4297ccd Compare May 28, 2023 21:00
When the input doesn't have a trailing newline, but the last line had
exactly the amount of bytes as the current indentation level, the
tokenizer didn't emit a fake newline, causing parse errors (the grammar
expects newlines to conform with the Python spec).

I don't see any reason for fake newlines to be omitted in these cases,
so this PR removes that condition from the tokenizer.

Reported in #930.
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (59aeceb) 90.92% compared to head (07a168b) 90.92%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #940   +/-   ##
=======================================
  Coverage   90.92%   90.92%           
=======================================
  Files         254      254           
  Lines       25937    25937           
=======================================
  Hits        23584    23584           
  Misses       2353     2353           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zsol zsol merged commit 5eec991 into main Jun 7, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants