Title: Encoding issue in the name of the local DST timezone
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: maggyero, p-ganssle, xtreak
Priority: normal Keywords:

Created on 2018-04-10 21:34 by maggyero, last changed 2018-09-14 17:23 by p-ganssle.

Messages (2)
msg315181 - (view) Author: Géry (maggyero) * Date: 2018-04-10 21:34
There seems to be an encoding bug in Python 3.6.5 on Windows with the [timezone constant]( `time.tzname`:

    >>> import time
    >>> time.tzname
    ('Paris, Madrid', 'Paris, Madrid (heure d\x92été)')

In the second string (the name of the local *DST* timezone), the escape sequence `\x92` is (since it is in a *character* string, not in a byte string) the Unicode code point [U+0092 PRIVATE USE 2 (PU2)](, instead of the Unicode code point [U+2019 RIGHT SINGLE QUOTATION MARK]( as expected, which would have been displayed as `’` or `\u2019`, so `'Paris, Madrid (heure d’été)'`.

This `\x92` obviously comes from the 0x92 byte of the [CP-1252 encoding]( for the `’` character, but the byte has been badly handled in `time.tzname` somehow.

Indeed, quoting the [‘Lexical analysis’]( chapter from the *Language Reference*:

> In a bytes literal, hexadecimal and octal escapes denote the byte with
> the given value. In a string literal, these escapes denote a Unicode
> character with the given value.
msg325334 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-14 08:37
Seems like formatting timezone names on Windows has a lot of issues. I don't if it's related to the ones reported before but just like to add reference comment with more issues :

Date User Action Args
2018-09-14 17:23:32p-gansslesetnosy: + p-ganssle
2018-09-14 08:37:10xtreaksetnosy: + xtreak
messages: + msg325334
2018-04-10 21:34:20maggyerocreate