diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-10 01:19:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 01:19:54 (GMT) |
commit | d267ac20c309e37d85a986b4417aa8ab4d05dabc (patch) | |
tree | 701e11585f2a69916429f798895ba6fac1ec0545 /Lib/encodings | |
parent | 137be34180a20dba53948d126b961069f299f153 (diff) | |
download | cpython-d267ac20c309e37d85a986b4417aa8ab4d05dabc.zip cpython-d267ac20c309e37d85a986b4417aa8ab4d05dabc.tar.gz cpython-d267ac20c309e37d85a986b4417aa8ab4d05dabc.tar.bz2 |
bpo-36778: cp65001 encoding becomes an alias to utf_8 (GH-13230)
Diffstat (limited to 'Lib/encodings')
-rw-r--r-- | Lib/encodings/aliases.py | 1 | ||||
-rw-r--r-- | Lib/encodings/cp65001.py | 43 |
2 files changed, 1 insertions, 43 deletions
diff --git a/Lib/encodings/aliases.py b/Lib/encodings/aliases.py index 2e63c2f..5ef40a3 100644 --- a/Lib/encodings/aliases.py +++ b/Lib/encodings/aliases.py @@ -534,6 +534,7 @@ aliases = { 'utf8' : 'utf_8', 'utf8_ucs2' : 'utf_8', 'utf8_ucs4' : 'utf_8', + 'cp65001' : 'utf_8', # uu_codec codec 'uu' : 'uu_codec', diff --git a/Lib/encodings/cp65001.py b/Lib/encodings/cp65001.py deleted file mode 100644 index 95cb2ae..0000000 --- a/Lib/encodings/cp65001.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -Code page 65001: Windows UTF-8 (CP_UTF8). -""" - -import codecs -import functools - -if not hasattr(codecs, 'code_page_encode'): - raise LookupError("cp65001 encoding is only available on Windows") - -### Codec APIs - -encode = functools.partial(codecs.code_page_encode, 65001) -_decode = functools.partial(codecs.code_page_decode, 65001) - -def decode(input, errors='strict'): - return codecs.code_page_decode(65001, input, errors, True) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input, final=False): - return encode(input, self.errors)[0] - -class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - _buffer_decode = _decode - -class StreamWriter(codecs.StreamWriter): - encode = encode - -class StreamReader(codecs.StreamReader): - decode = _decode - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name='cp65001', - encode=encode, - decode=decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamreader=StreamReader, - streamwriter=StreamWriter, - ) |