From 33531dd70e9bcbb639f122cda80060d17f2205fa Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Thu, 19 Jun 2025 12:46:33 +0100 Subject: [PATCH] [3.14] gh-133439: Fix the error message in the sqlite3 CLI (GH-133807) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ecd83e02b128bf0879d9bb1d3940e40bcb14bdc6) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Serhiy Storchaka --- Lib/sqlite3/__main__.py | 5 ++--- Lib/test/test_sqlite3/test_cli.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Lib/sqlite3/__main__.py b/Lib/sqlite3/__main__.py index 4ccf292ddf211c..bf1236b022ea1c 100644 --- a/Lib/sqlite3/__main__.py +++ b/Lib/sqlite3/__main__.py @@ -53,7 +53,7 @@ def runsource(self, source, filename="", symbol="single"): if source[0] == ".": match source[1:].strip(): case "version": - print(f"{sqlite3.sqlite_version}") + print(sqlite3.sqlite_version) case "help": print("Enter SQL code and press enter.") case "quit": @@ -61,8 +61,7 @@ def runsource(self, source, filename="", symbol="single"): case "": pass case _ as unknown: - self.write("Error: unknown command or invalid arguments:" - f' "{unknown}".\n') + self.write(f'Error: unknown command: "{unknown}"\n') else: if not sqlite3.complete_statement(source): return True diff --git a/Lib/test/test_sqlite3/test_cli.py b/Lib/test/test_sqlite3/test_cli.py index a03d7cbe16ba84..7e981c24fd143c 100644 --- a/Lib/test/test_sqlite3/test_cli.py +++ b/Lib/test/test_sqlite3/test_cli.py @@ -129,7 +129,7 @@ def test_interact_dot_commands_unknown(self): self.assertEndsWith(out, self.PS1) self.assertEqual(out.count(self.PS1), 2) self.assertEqual(out.count(self.PS2), 0) - self.assertIn("Error", err) + self.assertIn('Error: unknown command: "', err) # test "unknown_command" is pointed out in the error message self.assertIn("unknown_command", err)