@@ -146,6 +146,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
146
146
encoding = "utf-8" ,
147
147
timeout = TIMEOUT ,
148
148
cwd = initial_dir ,
149
+ codec_errors = "backslashreplace" ,
149
150
)
150
151
shell .sendline (
151
152
f"export PROMPT_COMMAND= PS1={ PROMPT_CONST } "
@@ -161,6 +162,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
161
162
echo = False ,
162
163
encoding = "utf-8" ,
163
164
timeout = TIMEOUT ,
165
+ codec_errors = "backslashreplace" ,
164
166
)
165
167
shell .sendline (f"export PS1={ PROMPT_CONST } " )
166
168
shell .expect (PROMPT_CONST , timeout = TIMEOUT )
@@ -256,7 +258,9 @@ def ensure_env_and_bg_jobs(self) -> Optional[int]:
256
258
before = "\n " .join (before_lines ).strip ()
257
259
counts += 1
258
260
if counts > 100 :
259
- raise ValueError ("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it" )
261
+ raise ValueError (
262
+ "Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
263
+ )
260
264
261
265
try :
262
266
return int (before )
@@ -273,7 +277,7 @@ def _init_shell(self) -> None:
273
277
self ._bash_command_mode .bash_mode == "restricted_mode" ,
274
278
self ._cwd ,
275
279
)
276
-
280
+
277
281
self ._pending_output = ""
278
282
279
283
# Get exit info to ensure shell is ready
@@ -414,7 +418,9 @@ def update_repl_prompt(self, command: str) -> bool:
414
418
index = self .shell .expect ([self ._prompt , pexpect .TIMEOUT ], timeout = 0.2 )
415
419
counts += 1
416
420
if counts > 100 :
417
- raise ValueError ("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it" )
421
+ raise ValueError (
422
+ "Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
423
+ )
418
424
console .print (f"Prompt updated to: { self ._prompt } " )
419
425
return True
420
426
return False
0 commit comments