BUG: UnicodeError when using Period.strftime with non-utf8 locale · Issue #46319 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd import locale

locale.setlocale(locale.LC_ALL, "zh_CN") p = pd.Period("2018-03-11 13:00", freq="H") print(p.strftime("%p")) # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf ...

Issue Description

Period.strftime("%p") prints the locale-specific version of AM or PM. When the locale uses a non-utf8 compliant encoding, it crashes.

This bug does not happen with others, for example Timestamp.strftime.

Expected Behavior

No error, printing the actual string representing AM or PM

Installed Versions

This is on the main branch head