bpo-39337: Add a test case for normalizing of codec names by shihai1991 · Pull Request #19069 · python/cpython (original) (raw)
You're welcome to add a comment after the doc-string. I wouldn't want the doc-string to mention normalizestring, though, unless we change the test to call normalizestring()
directly instead of codecs.lookup()
, which I don't recommend.
From my experience, however, such comments often become outdated when the implementation changes. And outdated comments causing confusion are usually worse than no comments.
Also, if someone needs to see the details, they'll likely need to go through the code starting at codecs.lookup()
anyways. It's relatively straightforward to follow: codecs
imports lookup
from _codecs
, implemented in Modules/_codecsmodule.c
. lookup()
is a simple wrapper for _PyCodec_Lookup
from Python/codecs.c
. With the imports and wrappers out of the way, _PyCodec_Lookup
calls normalizestring()
near the top of the function, immediately after a bit of initialization.