mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 02:34:59 +00:00
refactor: handle UnicodeEncodeError by recreating InputOutput object
This commit is contained in:
parent
cc053b0b04
commit
1e8f2cbbb9
1 changed files with 20 additions and 20 deletions
|
@ -384,31 +384,31 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
|
|
||||||
editing_mode = EditingMode.VI if args.vim else EditingMode.EMACS
|
editing_mode = EditingMode.VI if args.vim else EditingMode.EMACS
|
||||||
|
|
||||||
io = InputOutput(
|
def get_io(pretty):
|
||||||
args.pretty,
|
return InputOutput(
|
||||||
args.yes,
|
pretty,
|
||||||
args.input_history_file,
|
args.yes,
|
||||||
args.chat_history_file,
|
args.input_history_file,
|
||||||
input=input,
|
args.chat_history_file,
|
||||||
output=output,
|
input=input,
|
||||||
user_input_color=args.user_input_color,
|
output=output,
|
||||||
tool_output_color=args.tool_output_color,
|
user_input_color=args.user_input_color,
|
||||||
tool_error_color=args.tool_error_color,
|
tool_output_color=args.tool_output_color,
|
||||||
dry_run=args.dry_run,
|
tool_error_color=args.tool_error_color,
|
||||||
encoding=args.encoding,
|
dry_run=args.dry_run,
|
||||||
llm_history_file=args.llm_history_file,
|
encoding=args.encoding,
|
||||||
editingmode=editing_mode,
|
llm_history_file=args.llm_history_file,
|
||||||
)
|
editingmode=editing_mode,
|
||||||
|
)
|
||||||
|
|
||||||
|
io = get_io(args.pretty)
|
||||||
try:
|
try:
|
||||||
io.tool_output()
|
|
||||||
io.rule()
|
io.rule()
|
||||||
except UnicodeEncodeError as err:
|
except UnicodeEncodeError as err:
|
||||||
if io.pretty:
|
if not io.pretty:
|
||||||
io.pretty = False
|
|
||||||
io.tool_warning("Terminal does not support pretty output (UnicodeDecodeError)")
|
|
||||||
else:
|
|
||||||
raise err
|
raise err
|
||||||
|
io = get_io(False)
|
||||||
|
io.tool_warning("Terminal does not support pretty output (UnicodeDecodeError)")
|
||||||
|
|
||||||
if args.gui and not return_coder:
|
if args.gui and not return_coder:
|
||||||
if not check_streamlit_install(io):
|
if not check_streamlit_install(io):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue