komuw / naz

naz is an async SMPP client.
https://komuw.github.io/naz/
MIT License
39 stars 12 forks source link

fix codec overriding #210

Open komuw opened 4 years ago

komuw commented 4 years ago

see: https://github.com/komuw/naz/blob/8b1ec3d0724e0d86bdfa3b804261600bea65d82e/tests/test_codec.py#L177-L232

I had asked Marc-Andre Lemburg(author of codec module in python) whether you can override an inbuilt codec, and his reply:

It's not really supported to override builtin codecs via a search
function. The only way is to monkey patch the encodings package
module implementing the codec and then only if you manage to
implement this patching before the codec gets used for the first
time, since the codec subsystem uses a cache for codecs to improve
performance.

Note that the codec search function registry is mainly meant to
*add* new codecs, not to override existing ones.

This was via email.

We should re-architect based on this new info.