MCPcopy Index your code
hub / github.com/python/cpython / maybe_run_command

Function maybe_run_command

Lib/_pyrepl/simple_interact.py:117–130  ·  view source on GitHub ↗
(statement: str)

Source from the content-addressed store, hash-verified

115 show_ref_count = _is_x_showrefcount_set and _is_pydebug_build
116
117 def maybe_run_command(statement: str) -> bool:
118 statement = statement.strip()
119 if statement in console.locals or statement not in REPL_COMMANDS:
120 return False
121
122 reader = _get_reader()
123 reader.history.pop() # skip internal commands in history
124 command = REPL_COMMANDS[statement]
125 if callable(command):
126 # Make sure that history does not change because of commands
127 with reader.suspend_history(), reader.suspend_colorization():
128 command()
129 return True
130 return False
131
132 while True:
133 try:

Callers 1

Calls 4

suspend_historyMethod · 0.80
suspend_colorizationMethod · 0.80
stripMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…