Skip to content

Encoding issue with CP1252 / UTF-8 #138

@agudenus

Description

@agudenus

Environment: Windows 11 Pro
When running autcoder, for each feature I get this error message

Feature #71 testing failed
Exception in thread Thread-1 (_read_output):
Traceback (most recent call last):
  File "${USER_HOME}\AppData\Local\Programs\Python\Python313\Lib\threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "${USER_HOME}\AppData\Local\Programs\Python\Python313\Lib\threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "${AUTOCODER_FOLDER}\parallel_orchestrator.py", line 695, in _read_output
    for line in proc.stdout:
                ^^^^^^^^^^^
  File "${USER_HOME}\AppData\Local\Programs\Python\Python313\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 4693: character maps to <undefined>

I analysed the code in Visual Studio Code using Github Copilot which proposed the following changes to "popen_kwargs" (multiple occurences) in parallel_orchestrator.py._run_initializer
The reasons seems to be that popen takes CP1252 as standard encoding

            popen_kwargs = {
                "stdin": subprocess.DEVNULL,
                "stdout": subprocess.PIPE,
                "stderr": subprocess.STDOUT,
                "text": True,
+              "encoding": "utf-8",
+              "errors": "replace",
                "cwd": str(AUTOCODER_ROOT),  # Run from autocoder root for proper imports
                "env": {**os.environ, "PYTHONUNBUFFERED": "1"},
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions