Skip to content

Fix the output of syntax error example#30097

Closed
vivekvashist wants to merge 7 commits intopython:mainfrom
vivekvashist:fix_syntax_error_output
Closed

Fix the output of syntax error example#30097
vivekvashist wants to merge 7 commits intopython:mainfrom
vivekvashist:fix_syntax_error_output

Conversation

@vivekvashist
Copy link
Copy Markdown
Contributor

No description provided.

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Dec 14, 2021
@the-knights-who-say-ni

This comment was marked as resolved.

^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

The parser repeats the offending line and displays a little 'arrow' pointing at
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This no longer matches the example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @iritkatriel - just checking if you need anything from my side ??

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sentence just after the example looks like it needs to be updated as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've updated the sentence as requested - let me know if it looks good to you ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sentence below is now incorrect, it talks about a missing colon before print.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

^ This is still the case, requesting changes to make sure this is not missed.

@iritkatriel
Copy link
Copy Markdown
Member

@pablogsal with the irrelevant suggestion about comma, this doesn’t look like the best example to keep in the tutorial. What do you think?

@pablogsal
Copy link
Copy Markdown
Member

I agree, I would prefer also not to keep the specific errors in the docs just in case we change them in the future. Having the arrows is good, thought.

@taleinat
Copy link
Copy Markdown
Contributor

taleinat commented Jan 8, 2022

Friendly ping, @pablogsal and @iritkatriel?

@iritkatriel
Copy link
Copy Markdown
Member

@vivekvashist can you think of a better example, one that doesn’t generate an irrelevant suggestion?

@vivekvashist
Copy link
Copy Markdown
Contributor Author

@vivekvashist can you think of a better example, one that doesn’t generate an irrelevant suggestion?

Would this work ?

>>> greeting = 'Hello World'
>>> print greeting
  File "<stdin>", line 1
    print greeting
    ^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(greeting)?

@iritkatriel
Copy link
Copy Markdown
Member

I think that’s better, yes.

^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(greeting)?

The parser repeats the offending line and displays 'arrows' pointing at
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually now I see that this example doesn’t demonstrate what the text mentions - that the arrows point to where the error begins. Can we find an example where the arrows don’t cover the whole line?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually now I see that this example doesn’t demonstrate what the text mentions - that the arrows point to where the error begins. Can we find an example where the arrows don’t cover the whole line?

How about:

>>> a[1]] = 0
  File "<stdin>", line 1
    a[1]] = 0
        ^
SyntaxError: unmatched ']'

The quote used in the example is from Monty Python :)
@rhettinger
Copy link
Copy Markdown
Contributor

Closing and reopening to trigger the bots.

@rhettinger rhettinger closed this May 10, 2022
@rhettinger rhettinger reopened this May 10, 2022
^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

The parser repeats the offending line and displays a little 'arrow' pointing at
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

^ This is still the case, requesting changes to make sure this is not missed.

@bedevere-bot
Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@slateny
Copy link
Copy Markdown
Contributor

slateny commented Oct 2, 2022

@vivekvashist Would you still be interested in giving the PR a quick update per the comment above?

@vivekvashist
Copy link
Copy Markdown
Contributor Author

Apologies for the delay - just to refresh my memory what changes/updates are required ?

@slateny
Copy link
Copy Markdown
Contributor

slateny commented Oct 5, 2022

See this comment: #30097 (comment)

print('Are you suggesting that coconuts migrate?)
^
SyntaxError: unterminated string literal (detected at line 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change

Spurious whitespace

example, the error is detected at the function :func:`print`, since a colon
(``':'``) is missing before it. File name and line number are printed so you
example, the error is detected at the function :func:`print`, since a single quote
(``'``) is missing. Error message and line number is also printed so you
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you change it to "Error message," the old sentence is perfectly fine?

Comment on lines +21 to +22
print('Are you suggesting that coconuts migrate?)
^
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The caret is not aligned with the first quote?


>>> while True print('Hello world')
>>> print('Are you suggesting that coconuts migrate?)
File "<stdin>", line 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
File "<stdin>", line 1
File "<python-input-0>", line 1

Is that not standard for the new repl?

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 10, 2026
@StanFromIreland
Copy link
Copy Markdown
Member

Closing as stale, opened #148327 so that someone else can pick this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes docs Documentation in the Doc dir skip issue skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.