Skip to content

Commit 13338ff

Browse files
committed
use a global const to store the EOF key
Signed-off-by: Keming <[email protected]>
1 parent a6e2f6d commit 13338ff

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Lib/sqlite3/__main__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
from ._completer import completer
1616

1717

18+
EOF_KEY = "CTRL-Z" if sys.platform == "win32" else "CTRL-D"
19+
20+
1821
def execute(c, sql, suppress_errors=True, theme=theme_no_color):
1922
"""Helper that wraps execution of SQL code.
2023
@@ -41,13 +44,6 @@ def execute(c, sql, suppress_errors=True, theme=theme_no_color):
4144
sys.exit(1)
4245

4346

44-
def _eof_key():
45-
if sys.platform == "win32" and "idlelib.run" not in sys.modules:
46-
return "CTRL-Z"
47-
else:
48-
return "CTRL-D"
49-
50-
5147
class SqliteInteractiveConsole(InteractiveConsole):
5248
"""A simple SQLite REPL."""
5349

@@ -76,7 +72,7 @@ def runsource(self, source, filename="<input>", symbol="single"):
7672
print(f"Enter SQL code or one of the below commands, and press enter.\n\n"
7773
f"{t.builtin}.version{t.reset} Print underlying SQLite library version\n"
7874
f"{t.builtin}.help{t.reset} Print this help message\n"
79-
f"{t.builtin}.quit{t.reset} Exit the CLI, equivalent to {_eof_key()}\n")
75+
f"{t.builtin}.quit{t.reset} Exit the CLI, equivalent to {EOF_KEY}\n")
8076
case "quit":
8177
sys.exit(0)
8278
case "":
@@ -129,7 +125,7 @@ def main(*args):
129125
Connected to {db_name}
130126
131127
Each command will be run using execute() on the cursor.
132-
Type ".help" for more information; type ".quit" or {_eof_key()} to quit.
128+
Type ".help" for more information; type ".quit" or {EOF_KEY} to quit.
133129
""").strip()
134130

135131
theme = get_theme()

0 commit comments

Comments
 (0)