Skip to content

Commit 5ec7198

Browse files
committed
Ignore empty dot command
1 parent bb0c7d9 commit 5ec7198

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Lib/sqlite3/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def runsource(self, source, filename="<input>", symbol="single"):
5959
case "quit":
6060
sys.exit(0)
6161
case _ as unknown:
62-
print("Error: unknown command or invalid arguments: "
63-
f'"{unknown}". Enter ".help" for help')
62+
if unknown:
63+
print("Error: unknown command or invalid arguments:"
64+
f' "{unknown}". Enter ".help" for help')
6465
else:
6566
if not sqlite3.complete_statement(source):
6667
return True

Lib/test/test_sqlite3/test_cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ def test_interact_empty_source(self):
124124
self.assertEqual(out.count(self.PS2), 0)
125125

126126
def test_interact_dot_commands_unknown(self):
127-
out, err = self.run_cli(commands=(".unknown_command",))
127+
out, err = self.run_cli(commands=(".unknown_command", "."))
128128
self.assertIn(self.MEMORY_DB_MSG, err)
129129
self.assertEndsWith(out, self.PS1)
130-
self.assertEqual(out.count(self.PS1), 2)
130+
self.assertEqual(out.count(self.PS1), 3)
131131
self.assertEqual(out.count(self.PS2), 0)
132-
self.assertIn('Error: unknown command or invalid arguments: "unknown_command"', out)
132+
# test "unknown_command" is pointed out in the error message
133+
self.assertIn("unknown_command", out)
134+
# test ignore empty dot command "." to mimic sqlite3 CLI
135+
self.assertEqual(out.count('Error'), 1)
133136

134137
def test_interact_dot_commands_with_whitespaces(self):
135138
out, err = self.run_cli(commands=(".version ", ". version"))

0 commit comments

Comments
 (0)