Skip to content

iso-8859-1 Do not support Decode Chinese character #102772

@ghost

Description

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/handlers.py", line 184, in finish_response
    self.write(data)
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/handlers.py", line 287, in write
    self.send_headers()
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/handlers.py", line 346, in send_headers
    self._write(bytes(self.headers))
                ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/wsgiref/headers.py", line 142, in __bytes__
    return str(self).encode('iso-8859-1')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 1965-1967: ordinal not in range(256)

in headers.py line 141:

    def __bytes__(self):
        return str(self).encode('iso-8859-1')

can be:

    def __bytes__(self):
        return str(self).encode('utf-8')

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions