This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients ezio.melotti, ronaldoussoren, serhiy.storchaka, steven.daprano, vstinner, winvinc, xtreak
Date 2018-06-16.12:01:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529150484.86.0.56676864532.issue33865@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-06-16 12:01:24xtreaksetrecipients: + xtreak, ronaldoussoren, vstinner, ezio.melotti, steven.daprano, serhiy.storchaka, winvinc
2018-06-16 12:01:24xtreaksetmessageid: <1529150484.86.0.56676864532.issue33865@psf.upfronthosting.co.za>
2018-06-16 12:01:24xtreaklinkissue33865 messages
2018-06-16 12:01:24xtreakcreate