Skip to content

UTF-8 encoding error when writing config.py with non-ASCII characters in project names

Problem Description

The application crashes with a UTF-8 encoding error when processing Jira projects that contain non-ASCII characters (e.g., Chinese characters) in their names. The error occurs when the list_data() method tries to write project mappings to the config.py file.

Error Message

File "d:\Git\Temp\jira2lab\src\config.py", line 139
    SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa4 in position 16: invalid start byte

Steps to Reproduce

  1. Run the list script to fetch Jira projects
  2. Have projects with Chinese/non-ASCII characters in their names
  3. The script attempts to write these project names to config.py
  4. Python fails to parse the resulting config file due to encoding issues

Expected Behavior

The script should properly handle non-ASCII characters in project names and write them to the config file with correct UTF-8 encoding, allowing the config file to be parsed without errors.

Current Behavior

The script writes non-ASCII characters in a way that causes UTF-8 decoding errors when Python tries to parse the config file, resulting in a SyntaxError.

Environment

  • OS: Windows
  • Python version: 3.12.10
  • Jira projects contain Chinese characters