This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cgi.log() uses locale encoding
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: duplicate
Dependencies: Superseder: cgi uses the locale encoding for log files
View: 41139
Assigned To: Nosy List: ethan.furman, methane, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-04-03 11:14 by methane, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg390120 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2021-04-03 11:14
See cgi.initlog():
https://github.com/python/cpython/blob/b2a91e0c9ee18b50cc86b21211c2258520a9f5d0/Lib/cgi.py#L82

```
            logfp = open(logfile, "a")
```

This feature is not documented but can be used like this.

```
import cgi
cgi.logfile="myapp.log"
cgi.log("こんにちは")
```

I want to change log file encoding to UTF-8. Although this is backward incompatible change, it unlikely break user application because it just change the logfile encoding.

UTF-8 is safer than locale encoding because UTF-8 supports all valid Unicode strings.
msg390125 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-04-03 14:45
This is a duplicate of issue41139.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87877
2021-04-03 14:45:27serhiy.storchakasetstatus: open -> closed

superseder: cgi uses the locale encoding for log files

nosy: + serhiy.storchaka
messages: + msg390125
resolution: duplicate
stage: resolved
2021-04-03 11:30:54xtreaksetnosy: + ethan.furman
2021-04-03 11:20:14methanesettitle: cgi.log() uses default encoding -> cgi.log() uses locale encoding
2021-04-03 11:14:45methanecreate