Skip to content

Commit caf47bc

Browse files
committed
Remove "Enter .help" message; Redirect error to stderr
1 parent 5ec7198 commit caf47bc

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Lib/sqlite3/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ def runsource(self, source, filename="<input>", symbol="single"):
5858
print("Enter SQL code and press enter.")
5959
case "quit":
6060
sys.exit(0)
61+
case "":
62+
pass
6163
case _ as unknown:
62-
if unknown:
63-
print("Error: unknown command or invalid arguments:"
64-
f' "{unknown}". Enter ".help" for help')
64+
self.write("Error: unknown command or invalid arguments:"
65+
f' "{unknown}".\n')
6566
else:
6667
if not sqlite3.complete_statement(source):
6768
return True

Lib/test/test_sqlite3/test_cli.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,21 @@ 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), 3)
130+
self.assertEqual(out.count(self.PS1), 2)
131131
self.assertEqual(out.count(self.PS2), 0)
132+
self.assertIn("Error", err)
132133
# 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)
134+
self.assertIn("unknown_command", err)
135+
136+
def test_interact_dot_commands_empty(self):
137+
out, err = self.run_cli(commands=("."))
138+
self.assertIn(self.MEMORY_DB_MSG, err)
139+
self.assertEndsWith(out, self.PS1)
140+
self.assertEqual(out.count(self.PS1), 2)
141+
self.assertEqual(out.count(self.PS2), 0)
136142

137143
def test_interact_dot_commands_with_whitespaces(self):
138144
out, err = self.run_cli(commands=(".version ", ". version"))

0 commit comments

Comments
 (0)