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.reader Error message indicates to use deprecated
Type: behavior Stage: patch review
Components: Extension Modules Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Philip Martin, SilentGhost, martin.panter, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-03-27 00:45 by Philip Martin, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
issue26648.diff SilentGhost, 2016-03-27 08:13 review
issue26648_2.diff SilentGhost, 2016-03-27 11:29 review
Messages (5)
msg262502 - (view) Author: Philip Martin (Philip Martin) Date: 2016-03-27 00:45
Currently, the error message:

_csv.Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

is cryptic in that universal line mode has been deprecated, and will not run in Python 3.5., i.e.:
open(escape_path, "rU", encoding=ENCODING)
>>> DeprecationWarning: 'U' mode is deprecated

I think a message indicating a suggestion to open the file with newline='' to enable universal line mode is more insightful.
msg262511 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-03-27 08:13
While the 'U' mode has been deprecated it doesn't mean that your example doesn't run in 3.5 - it runs just fine and will keep doing so until 4.0

I'm attaching patch that suggests using newline=None (even though it's a default value for open), as that what seems to better correspond to the old 'U' mode.
msg262517 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-03-27 11:10
Isn’t using newline=None a way to produce the error in the first place? Silent Ghost: see the footnote <https://docs.python.org/3/library/csv.html#id3>.

Reading with newline=None translates newlines. Writing with newline=None produces CRLFs on Windows. I understand the CSV module wants neither of these translations, so it has full control of the code points.
msg262519 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-03-27 11:29
Ah, the bit about csv module doing it's own newline handling is what I missed. Here is the updated patch.
msg262520 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-27 11:34
When this error is triggered at all?
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70835
2016-03-27 11:34:39serhiy.storchakasetmessages: + msg262520
2016-03-27 11:29:15SilentGhostsetfiles: + issue26648_2.diff

messages: + msg262519
2016-03-27 11:10:30martin.pantersetnosy: + martin.panter
messages: + msg262517
2016-03-27 08:13:47SilentGhostsetfiles: + issue26648.diff

type: enhancement -> behavior
components: + Extension Modules
versions: + Python 3.6, - Python 3.5
keywords: + patch
nosy: + SilentGhost, serhiy.storchaka

messages: + msg262511
stage: patch review
2016-03-27 00:45:05Philip Martincreate