Skip to content
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

Closed
vadmium opened this issue Dec 17, 2014 · 13 comments
Closed

codecs.__all__ incomplete #67260

vadmium opened this issue Dec 17, 2014 · 13 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@vadmium
Copy link
Member

vadmium commented Dec 17, 2014

BPO 23071
Nosy @malemburg, @berkerpeksag, @vadmium, @serhiy-storchaka
Files
  • codecs-all.patch
  • codecs-all.patch
  • 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:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2014-12-20.16:43:38.782>
    created_at = <Date 2014-12-17.04:53:33.196>
    labels = ['easy', 'type-bug', 'library']
    title = 'codecs.__all__ incomplete'
    updated_at = <Date 2014-12-20.17:02:05.593>
    user = 'https://github.com/vadmium'

    bugs.python.org fields:

    activity = <Date 2014-12-20.17:02:05.593>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-12-20.16:43:38.782>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2014-12-17.04:53:33.196>
    creator = 'martin.panter'
    dependencies = []
    files = ['37486', '37491']
    hgrepos = []
    issue_num = 23071
    keywords = ['patch', 'easy']
    message_count = 13.0
    messages = ['232800', '232808', '232809', '232852', '232854', '232861', '232867', '232869', '232972', '232974', '232975', '232976', '232977']
    nosy_count = 5.0
    nosy_names = ['lemburg', 'python-dev', 'berker.peksag', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23071'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 17, 2014

    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']

    @vadmium vadmium added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 17, 2014
    @serhiy-storchaka
    Copy link
    Member

    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.

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 17, 2014

    Okay I will try and make a patch for this once I have finished a patch to revise the documentation for bpo-19548

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 18, 2014

    Here is the patch (against the default branch)

    @berkerpeksag
    Copy link
    Member

    Thanks! Could you also add a test? See PublicAPITests in Lib/test/test_shutil.py as an example.

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 18, 2014

    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__.

    @serhiy-storchaka
    Copy link
    Member

    LGTM.

    @malemburg
    Copy link
    Member

    +1

    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 20, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 20, 2014

    New changeset c6491d91d59a by Serhiy Storchaka in branch '2.7':
    Issue bpo-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 bpo-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 bpo-23071: Added missing names to codecs.__all__. Patch by Martin Panter.
    https://hg.python.org/cpython/rev/73086376ed3c

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your patch Martin.

    @berkerpeksag
    Copy link
    Member

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 20, 2014

    New changeset 1ab04bcd03bf by Serhiy Storchaka in branch '3.4':
    Issue bpo-23071: "namereplace_errors" was added only in 3.5.
    https://hg.python.org/cpython/rev/1ab04bcd03bf

    @serhiy-storchaka
    Copy link
    Member

    Hmm, I have no ideas how I missed this when ran tests. Thank you Berker.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants