Skip to content

gh-133439: Fix the error message in the sqlite3 CLI #133807

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 10 commits into from
Jun 19, 2025

Conversation

StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented May 10, 2025

  • Use print for file consistency
  • Actually test for the full improved error message
  • Correct error message, messages do not have the '.'

Request: @erlend-aasland

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I don't think this PR is needed anymore, except maybe for the assertIn

@StanFromIreland
Copy link
Member Author

Should the error message not be consistent with all other cpython error messages?

I think it is still better to use print for clarity (we don't have to look it up) and consistency, all other writing in the file is done so.

@picnixz
Copy link
Member

picnixz commented May 10, 2025

I think it is still better to use print for clarity (we don't have to look it up) and consistency, all other writing in the file is done so.

I guess so. I actually expected InteractiveConsole to have a write_stderr and a write_stdout but there's none, so maybe only using print makes sense. WDYT @erlend-aasland?

@picnixz picnixz changed the title gh-133439: Fixup sqlite3 changes in 133440 gh-133439: simplify how errors are reported by sqlite3 CLI May 10, 2025
Co-authored-by: Bénédikt Tran <[email protected]>
@StanFromIreland StanFromIreland requested a review from picnixz May 10, 2025 08:34
@picnixz picnixz added the needs backport to 3.14 bugs and security fixes label May 10, 2025
@StanFromIreland
Copy link
Member Author

While working on something else I realized the current error message is error-ed even more:

sqlite> .HELP 
Error: unknowncommand or invalid arguments:  "HELP".

Friendly ping @erlend-aasland

@erlend-aasland
Copy link
Contributor

Stan, did you want to include further amendments in this PR?

@StanFromIreland
Copy link
Member Author

I don't mind, I can include it here. All that is to be done for the . help is to just use .rstrip instead of .strip.

@@ -70,8 +70,9 @@ def runsource(self, source, filename="<input>", symbol="single"):
pass
case _ as unknown:
t = theme.traceback
self.write(f'{t.type}Error{t.reset}:{t.message} unknown'
f'command or invalid arguments: "{unknown}".\n{t.reset}')
print(f'{t.type}Error{t.reset}:{t.message} unknown command '
Copy link
Member

Choose a reason for hiding this comment

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

Note that the banner and tracebacks are written using self.write(). Why not use it here for consistence?

Copy link
Member Author

Choose a reason for hiding this comment

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

Errors (35) use print? And so do the other match statements branches.

Copy link
Member

Choose a reason for hiding this comment

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

Other branches output to stdout.

Line 35 perhaps should use self.write() too.

Copy link
Member

Choose a reason for hiding this comment

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

We can leave execute() for now. It is not worth to rewrite it just for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
print(f'{t.type}Error{t.reset}:{t.message} unknown command '
self.write(f'{t.type}Error{t.reset}:{t.message} unknown command '

It is up to you/Erlend. The box to allow you to commit was checked.

@serhiy-storchaka serhiy-storchaka changed the title gh-133439: simplify how errors are reported by sqlite3 CLI gh-133439: Fix the error message in the sqlite3 CLI Jun 13, 2025
@encukou encukou merged commit ecd83e0 into python:main Jun 19, 2025
38 checks passed
@miss-islington-app
Copy link

Thanks @StanFromIreland for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @StanFromIreland and @encukou, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ecd83e02b128bf0879d9bb1d3940e40bcb14bdc6 3.14

@StanFromIreland
Copy link
Member Author

StanFromIreland commented Jun 19, 2025

The original was "backported" to 3.13 but it seems it was modified:

self.write("Error: unknown command or invalid arguments:"
f' "{unknown}".\n')

@encukou Should we backport this (to 3.13) too so they are the same?

@bedevere-app
Copy link

bedevere-app bot commented Jun 19, 2025

GH-135708 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jun 19, 2025
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Jun 19, 2025
…honGH-133807)

(cherry picked from commit ecd83e0)

Co-authored-by: Stan Ulbrych <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
@StanFromIreland StanFromIreland deleted the sqlite3-fixup branch June 19, 2025 12:33
@encukou
Copy link
Member

encukou commented Jun 19, 2025

Now that I look at the diff, I don't see a bug to fix in 3.14.

@StanFromIreland
Copy link
Member Author

There is no bug because the author modified the backport, the message is different though.

lkollar pushed a commit to lkollar/cpython that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants