Skip to content

csv module docstring imported from _csv module #114123

Closed
@smontanaro

Description

@smontanaro

Documentation

While messing around trying to find undocumented module attributes, I noticed that csv.__all__ contains both __doc__ and __version__. Those inclusions are themselves weird, but I further noticed this:

from _csv import Error, __version__, writer, reader, register_dialect, \
                 unregister_dialect, get_dialect, list_dialects, \
                 field_size_limit, \
                 QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \
                 QUOTE_STRINGS, QUOTE_NOTNULL, \
                 __doc__

Note that both attributes are imported from the underlying _csv module. Furthermore, the __doc__ attribute is pretty extensive.

I see no particular reason either attribute needs to be defined in the underlying C module. In particular, maintaining a docstring in C (with its constrainged multi-line string syntax) is much more difficult than in Python (with its rather nice triple-quoted string syntax).

I hope I wasn't the ultimate source of this problem. I suspect that in pulling non-performance-critical bits out of the old CSV module (when it was written entirely in C) these two attributes were just missed.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions