I’ve been reading some of the source on this and understand a bit better the mechanism of lazy evaluation of encodings.
I understand only a few selected encodings present on /lib/python/encodings/ are evaluated at startup, i’ve tested this by running stuff like
PYTHONIOENCODING=rot13 python and seeing if i get a lookup error.
My question being, is it possible, and if so how, may one get his custom encoding registered at startup?
What i currently have: a custom codec and a .pth that loads it in site_packages
problem is: PYTHONIOENCODING is processed before the codec gets registered (which is logical i guess, it’s got to decode the pth file somehow), so that by the time i do
PYTHONIOENCODING=my_enc python, the interpreter didn’t really register my codec resulting in a LookupError.