Skip to content

Commit d9f9dc6

Browse files
committed
Soften hardcoding of ps1 and ps2 for easier future adoption in pdb
1 parent 1b51aea commit d9f9dc6

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎Lib/_pyrepl/readline.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ def _should_auto_indent(buffer: list[str], pos: int) -> bool:
297297
_REPL_PASTE_HINT = "press F3 (paste mode) to strip >>> and ... prompts"
298298

299299

300-
def _is_repl_session(data: str) -> bool:
301-
return data[:3] in {">>>", "..."} and data[3:4] in {"", " ", "\r", "\n"}
300+
def _is_repl_session(data: str, *, ps1: str, ps2: str) -> bool:
301+
return data[:3] in (ps1, ps2) and data[3:4] in {"", " ", "\r", "\n"}
302302

303303

304-
def _strip_repl_prompts(data: str) -> str:
304+
def _strip_repl_prompts(data: str, *, ps1: str = ">>>", ps2: str = "...") -> str:
305305
lines: list[str] = []
306306
statement_start = None
307307
for line in re.findall(r"[^\r\n]*(?:\r\n?|\n|$)", data):
308-
if _is_repl_session(line):
309-
if line.startswith(">>>") or statement_start is None:
308+
if _is_repl_session(line, ps1=ps1, ps2=ps2):
309+
if line.startswith(ps1) or statement_start is None:
310310
statement_start = len(lines)
311311
lines.append(line[3:].removeprefix(" "))
312312
elif statement_start is not None:

0 commit comments

Comments
 (0)