classification
Title: codecs.__all__ incomplete
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, lemburg, martin.panter, python-dev, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2014-12-17 04:53 by martin.panter, last changed 2014-12-20 17:02 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
codecs-all.patch martin.panter, 2014-12-18 03:40 review
codecs-all.patch martin.panter, 2014-12-18 07:08 review
Messages (13)
msg232800 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-17 04:53
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']
msg232808 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-17 07:35
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.
msg232809 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-17 07:54
Okay I will try and make a patch for this once I have finished a patch to revise the documentation for Issue 19548
msg232852 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-18 03:40
Here is the patch (against the default branch)
msg232854 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-12-18 03:45
Thanks! Could you also add a test? See PublicAPITests in Lib/test/test_shutil.py as an example.
msg232861 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-18 07:08
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__.
msg232867 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-18 09:59
LGTM.
msg232869 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2014-12-18 10:33
+1
msg232972 - (view) Author: Roundup Robot (python-dev) Date: 2014-12-20 15:52
New changeset c6491d91d59a by Serhiy Storchaka in branch '2.7':
Issue #23071: Added missing names to codecs.__all__.  Patch by Martin Panter.
https://hg.python.org/cpython/rev/c6491d91d59a

New changeset 2b642f2ca391 by Serhiy Storchaka in branch '3.4':
Issue #23071: Added missing names to codecs.__all__.  Patch by Martin Panter.
https://hg.python.org/cpython/rev/2b642f2ca391

New changeset 73086376ed3c by Serhiy Storchaka in branch 'default':
Issue #23071: Added missing names to codecs.__all__.  Patch by Martin Panter.
https://hg.python.org/cpython/rev/73086376ed3c
msg232974 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-20 16:43
Thank you for your patch Martin.
msg232975 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-12-20 16:45
In 3.4, "namereplace_errors" needs to be removed in the test:

    https://hg.python.org/cpython/rev/2b642f2ca391#l2.17

======================================================================
FAIL: test_all (test.test_codecs.CodecsModuleTest)
----------------------------------------------------------------------
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
msg232976 - (view) Author: Roundup Robot (python-dev) Date: 2014-12-20 17:00
New changeset 1ab04bcd03bf by Serhiy Storchaka in branch '3.4':
Issue #23071: "namereplace_errors" was added only in 3.5.
https://hg.python.org/cpython/rev/1ab04bcd03bf
msg232977 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-12-20 17:02
Hmm, I have no ideas how I missed this when ran tests. Thank you Berker.
History
Date User Action Args
2014-12-20 17:02:05serhiy.storchakasetmessages: + msg232977
2014-12-20 17:00:50python-devsetmessages: + msg232976
2014-12-20 16:45:03berker.peksagsetmessages: + msg232975
2014-12-20 16:43:38serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg232974

stage: patch review -> resolved
2014-12-20 15:52:15python-devsetnosy: + python-dev
messages: + msg232972
2014-12-20 15:31:21serhiy.storchakasetassignee: serhiy.storchaka
2014-12-18 10:33:56lemburgsetnosy: + lemburg
messages: + msg232869
2014-12-18 09:59:50serhiy.storchakasetmessages: + msg232867
2014-12-18 07:08:02martin.pantersetfiles: + codecs-all.patch

messages: + msg232861
2014-12-18 03:45:44berker.peksagsetmessages: + msg232854
stage: needs patch -> patch review
2014-12-18 03:40:10martin.pantersetfiles: + codecs-all.patch
keywords: + patch
messages: + msg232852
2014-12-17 07:54:37martin.pantersetmessages: + msg232809
2014-12-17 07:35:46serhiy.storchakasetversions: + Python 2.7, Python 3.5
nosy: + serhiy.storchaka

messages: + msg232808

keywords: + easy
stage: needs patch
2014-12-17 04:56:15berker.peksagsetnosy: + berker.peksag
2014-12-17 04:53:33martin.pantercreate