This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: csv.Error description is incorrectly broad
Type: Stage: resolved
Components: Documentation Versions: Python 3.3, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, docs@python, xmorel
Priority: normal Keywords:

Created on 2012-08-13 12:44 by xmorel, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg168096 - (view) Author: Xavier Morel (xmorel) * Date: 2012-08-13 12:44
In both Python 2.7 and Python 3.x, csv.Error is documented as:

    Raised by any of the functions when an error is detected.

As far as I can tell from using the module and looking at the code, this is completely incorrect. There is actually a single instance of csv.Error being used: the instantiation of csv.Dialect (which converts TypeError raised from _csv._Dialect() into csv.Error, a comment notes that this is "for compatibility with py 2.3").

And the only way to hit that code paths seems to be subclassing `Dialect` and putting incorrect values in the various attributes (providing them to `csv.reader` raises a TypeError).

I believe the documentation to csv.Error should be changed to:

1. Mark it as effectively deprecated
2. Indicate that the only situation in which it it may be raised is when initializing a subclass of csv.Dialect
msg168194 - (view) Author: Xavier Morel (xmorel) * Date: 2012-08-14 12:28
Correction: csv also seems to raise csv.Error if the file contains NUL bytes:

    Error: line contains NULL byte
msg272074 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-08-05 23:40
Thanks for the report.

Most of the csv.Error usages are in Modules/_csv.c. You can search for "_csvstate_global->error_obj" in the module's source code. I think the documentation is correct as is.
History
Date User Action Args
2022-04-11 14:57:34adminsetgithub: 59844
2016-08-05 23:40:54berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg272074

resolution: not a bug
stage: resolved
2012-08-14 12:28:32xmorelsetmessages: + msg168194
2012-08-13 12:44:59xmorelcreate