Update encodings module to CPython 3.8

This commit is contained in:
Padraic Fanning committed 2021-09-04 18:24:31 -04:00
1 parent 704c2d1240
commit d50ff55822
4 files changed
+11 -5

No files matched your search

+3 -4
View File
@@ -12,7 +12,7 @@
* getregentry() -> codecs.CodecInfo object
The getregentry() API must return a CodecInfo object with encoder, decoder,
incrementalencoder, incrementaldecoder, streamwriter and streamreader
atttributes which adhere to the Python Codec Interface Standard.
attributes which adhere to the Python Codec Interface Standard.
In addition, a module may optionally also define the following
APIs which are then used by the package's codec search function:
@@ -49,8 +49,7 @@ def normalize_encoding(encoding):
collapsed and replaced with a single underscore, e.g. ' -;#'
becomes '_'. Leading and trailing underscores are removed.
Note that encoding names should be ASCII only; if they do use
non-ASCII characters, these must be Latin-1 compatible.
Note that encoding names should be ASCII only.
"""
if isinstance(encoding, bytes):
@@ -58,7 +57,7 @@ def normalize_encoding(encoding):
chars = []
punct = False
for c in encoding.lower():
for c in encoding:
if c.isalnum() or c == '.':
if punct and chars:
chars.append('_')
+3
View File
@@ -266,6 +266,8 @@ aliases = {
'roman8' : 'hp_roman8',
'r8' : 'hp_roman8',
'csHPRoman8' : 'hp_roman8',
'cp1051' : 'hp_roman8',
'ibm1051' : 'hp_roman8',
# hz codec
'hzgb' : 'hz',
@@ -534,6 +536,7 @@ aliases = {
'utf8' : 'utf_8',
'utf8_ucs2' : 'utf_8',
'utf8_ucs4' : 'utf_8',
'cp65001' : 'utf_8',
# uu_codec codec
'uu' : 'uu_codec',
+1 -1
View File
@@ -143,7 +143,7 @@ def decode_generalized_number(extended, extpos, bias, errors):
digit = char - 22 # 0x30-26
elif errors == "strict":
raise UnicodeError("Invalid extended code point '%s'"
% extended[extpos])
% extended[extpos-1])
else:
return extpos, None
t = T(j, bias)
+4
View File
@@ -20,6 +20,10 @@ def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
read = infile.read
write = outfile.write
# Remove newline chars from filename
filename = filename.replace('\n','\\n')
filename = filename.replace('\r','\\r')
# Encode
write(('begin %o %s\n' % (mode & 0o777, filename)).encode('ascii'))
chunk = read(45)