Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

I am able to verify the newly added aliases using the below assert statement

assert codecs.encode('a', '874') == codecs.encode('a', 'cp874')

I am struck on the part where it could be patched in the search_function and I 
hope this is the approach @serhiy.storchaka was making. After the usual logic I 
am checking if the aliased_encoding is None and if the normalized_encoding is 
all digits then I am prepending 'cp' in front and calling search_function again 
so that cases like '936' first look at the table which has higher precedence 
and then for other cases even though an entry is not present it returns 
'cpXXXX' encoder. 

I have tested it by removing newly added '874' from aliases.py so that instead 
of an error 'cp874' is returned. Since in the next call the case of encoding 
being digits is not valid due to prepending 'cp' there will be no error due to 
infinite recursion for wrong ones.

Thanks

----------
Added file: https://bugs.python.org/file47643/33865.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33865>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to