Closed
Description
Bug report
In 0729b31 (#91982), @methane implemented encoding="locale"
support for TextIOWrapper.reconfigure
.
However, the implementation in _pyio.py
can't possibly work, as locale
is not imported in the scope it's used:
Line 2165 in 760ec89
it's only imported locally in __init__
:
Lines 2024 to 2031 in 760ec89
Thus causing python -c 'import _pyio as io; wrapper = io.TextIOWrapper(io.BytesIO(b"test")); wrapper.reconfigure(encoding="locale")'
to fail with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.11/_pyio.py", line 2165, in reconfigure
encoding = locale.getencoding()
^^^^^^
NameError: name 'locale' is not defined. Did you mean: 'locals'?
(Found by running flake8
over Lib/
out of curiosity, see #93010 (comment))
Your environment
- CPython versions tested on: Python 3.11.0b1
- Operating system and architecture: Archlinux x86_64