Skip to content

Uncaught UnicodeEncodeError in console.py line 2097 #5128

@aurelehe

Description

@aurelehe

Aider version: 0.86.2
Python version: 3.12.13
Platform: Windows-11-10.0.26200-SP0
Python implementation: CPython
Virtual environment: Yes
OS: Windows 11 (64bit)
Git version: git version 2.53.0.windows.2

An uncaught exception occurred:

Traceback (most recent call last):
  File "io.py", line 980, in _tool_message
    self.console.print(message, **style)
  File "console.py", line 1697, in print
    with self:
         ^^^^
  File "console.py", line 870, in __exit__
    self._exit_buffer()
  File "console.py", line 826, in _exit_buffer
    self._check_buffer()
  File "console.py", line 2042, in _check_buffer
    self._write_buffer()
  File "console.py", line 2097, in _write_buffer
    write("".join(batch))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 2828-2829: surrogates not allowed
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "commands.py", line 296, in do_run
    return cmd_method(args)
           ^^^^^^^^^^^^^^^^
  File "commands.py", line 176, in cmd_chat_mode
    self.io.tool_error(f'Chat mode "{ef}" should be one of these:\n')
  File "io.py", line 990, in tool_error
    self._tool_message(message, strip, self.tool_error_color)
  File "io.py", line 986, in _tool_message
    self.console.print(message, **style)
  File "console.py", line 1697, in print
    with self:
         ^^^^
  File "console.py", line 870, in __exit__
    self._exit_buffer()
  File "console.py", line 826, in _exit_buffer
    self._check_buffer()
  File "console.py", line 2042, in _check_buffer
    self._write_buffer()
  File "console.py", line 2097, in _write_buffer
    write("".join(batch))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 2828-2829: surrogates not allowed
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "io.py", line 980, in _tool_message
    self.console.print(message, **style)
  File "console.py", line 1697, in print
    with self:
         ^^^^
  File "console.py", line 870, in __exit__
    self._exit_buffer()
  File "console.py", line 826, in _exit_buffer
    self._check_buffer()
  File "console.py", line 2042, in _check_buffer
    self._write_buffer()
  File "console.py", line 2097, in _write_buffer
    write("".join(batch))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 2828-2829: surrogates not allowed
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "__main__.py", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 1162, in main
    coder.run()
  File "base_coder.py", line 887, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 928, in run_one
    message = self.preproc_user_input(user_message)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 917, in preproc_user_input
    return self.commands.run(inp)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "commands.py", line 324, in run
    return self.do_run(command, rest_inp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "commands.py", line 298, in do_run
    self.io.tool_error(f"Unable to complete {cmd_name}: {err}")
  File "io.py", line 990, in tool_error
    self._tool_message(message, strip, self.tool_error_color)
  File "io.py", line 986, in _tool_message
    self.console.print(message, **style)
  File "console.py", line 1697, in print
    with self:
         ^^^^
  File "console.py", line 870, in __exit__
    self._exit_buffer()
  File "console.py", line 826, in _exit_buffer
    self._check_buffer()
  File "console.py", line 2042, in _check_buffer
    self._write_buffer()
  File "console.py", line 2097, in _write_buffer
    write("".join(batch))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 2828-2829: surrogates not allowed
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions