Handle alternate names for UTF-8 encoding #3322
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue
Currently, pipenv does this:
__init__.py
,sys.stdout
andsys.stderr
are replaced byio.TextIOWrapper
s withencoding
set to'utf8'
(no dash):pipenv/pipenv/__init__.py
Lines 31 to 36 in d9ebad3
_compat.py
, the encoding is forced to UTF-8 by checking ifsys.stdout/err.encoding.lower()
is equal to'utf-8'
(with a dash):pipenv/pipenv/_compat.py
Line 331 in d9ebad3
Fixes #3313.
The fix
codecs.lookup()
. This will always return'utf-8'
for UTF-8 encodings, no matter what alias is used ('utf8'
,'UTF-8'
,'u8'
, etc.)ImportError
when importingctypes
, so that this code path doesn't crash with PyPy (which doesn't support ctypes). @frostming mentioned in Incompatibility with pypy3 #3313 that pipenv doesn't officially support PyPy so I can remove this if you'd prefer, but it seems like a net improvement to me.The checklist
news/
directory:3313.bugfix.rst