New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codecs.__all__ incomplete #67260
Comments
First ones I noticed were codecs.encode() and codecs.decode(). Here is a list of other candidates, although they are not all documented, so maybe should not all be in __all__. >>> import codecs
>>> public = (a for a in dir(codecs) if not a.startswith("_"))
>>> sorted(set(public).difference(codecs.__all__))
['BufferedIncrementalDecoder', 'BufferedIncrementalEncoder', 'Codec', 'CodecInfo', 'IncrementalDecoder', 'IncrementalEncoder', 'StreamReader', 'StreamReaderWriter', 'StreamRecoder', 'StreamWriter', 'ascii_decode', 'ascii_encode', 'backslashreplace_errors', 'builtins', 'charmap_build', 'charmap_decode', 'charmap_encode', 'decode', 'encode', 'escape_decode', 'escape_encode', 'getdecoder', 'getencoder', 'getincrementaldecoder', 'getincrementalencoder', 'getreader', 'getwriter', 'iterdecode', 'iterencode', 'latin_1_decode', 'latin_1_encode', 'make_encoding_map', 'make_identity_dict', 'raw_unicode_escape_decode', 'raw_unicode_escape_encode', 'readbuffer_encode', 'sys', 'unicode_escape_decode', 'unicode_escape_encode', 'unicode_internal_decode', 'unicode_internal_encode', 'utf_16_be_decode', 'utf_16_be_encode', 'utf_16_decode', 'utf_16_encode', 'utf_16_ex_decode', 'utf_16_le_decode', 'utf_16_le_encode', 'utf_32_be_decode', 'utf_32_be_encode', 'utf_32_decode', 'utf_32_encode', 'utf_32_ex_decode', 'utf_32_le_decode', 'utf_32_le_encode', 'utf_7_decode', 'utf_7_encode', 'utf_8_decode', 'utf_8_encode'] |
Yes, only documented names should be in __all__. Do you want to provide a patch Martin? Suggestion: first filter names which are contained in codecs.rst. |
Okay I will try and make a patch for this once I have finished a patch to revise the documentation for bpo-19548 |
Here is the patch (against the default branch) |
Thanks! Could you also add a test? See PublicAPITests in Lib/test/test_shutil.py as an example. |
This patch includes a new test; although this kind of testing won’t detect when someone adds a new API and forgets to add it to __all__. |
LGTM. |
+1 |
New changeset c6491d91d59a by Serhiy Storchaka in branch '2.7': New changeset 2b642f2ca391 by Serhiy Storchaka in branch '3.4': New changeset 73086376ed3c by Serhiy Storchaka in branch 'default': |
Thank you for your patch Martin. |
In 3.4, "namereplace_errors" needs to be removed in the test:
====================================================================== Traceback (most recent call last):
File "/usr/home/buildbot/python/3.4.koobs-freebsd9/build/Lib/test/test_codecs.py", line 1668, in test_all
self.assertCountEqual(api, codecs.__all__)
AssertionError: Element counts were not equal:
First has 1, Second has 0: 'namereplace_errors' http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.x%203.4/builds/645/steps/test/logs/stdio |
New changeset 1ab04bcd03bf by Serhiy Storchaka in branch '3.4': |
Hmm, I have no ideas how I missed this when ran tests. Thank you Berker. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: