The Wayback Machine - https://web.archive.org/web/20240108134109/https://github.com/python/cpython/issues/70835
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

csv.reader Error message indicates to use deprecated #70835

Open
PhilipMartin mannequin opened this issue Mar 27, 2016 · 5 comments
Open

csv.reader Error message indicates to use deprecated #70835

PhilipMartin mannequin opened this issue Mar 27, 2016 · 5 comments
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@PhilipMartin
Copy link
Mannequin

PhilipMartin mannequin commented Mar 27, 2016

BPO 26648
Nosy @vadmium, @serhiy-storchaka
Files
  • issue26648.diff
  • issue26648_2.diff
  • 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 = None
    closed_at = None
    created_at = <Date 2016-03-27.00:45:05.510>
    labels = ['extension-modules', 'type-bug']
    title = 'csv.reader Error message indicates to use deprecated'
    updated_at = <Date 2016-03-27.11:34:39.384>
    user = 'https://bugs.python.org/PhilipMartin'

    bugs.python.org fields:

    activity = <Date 2016-03-27.11:34:39.384>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2016-03-27.00:45:05.510>
    creator = 'Philip Martin'
    dependencies = []
    files = ['42304', '42306']
    hgrepos = []
    issue_num = 26648
    keywords = ['patch']
    message_count = 5.0
    messages = ['262502', '262511', '262517', '262519', '262520']
    nosy_count = 4.0
    nosy_names = ['SilentGhost', 'martin.panter', 'serhiy.storchaka', 'Philip Martin']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26648'
    versions = ['Python 3.6']

    Linked PRs

    @PhilipMartin
    Copy link
    Mannequin Author

    PhilipMartin mannequin commented Mar 27, 2016

    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.

    @PhilipMartin PhilipMartin mannequin added the type-feature A feature request or enhancement label Mar 27, 2016
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Mar 27, 2016

    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.

    @SilentGhost SilentGhost mannequin added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Mar 27, 2016
    @vadmium
    Copy link
    Member

    vadmium commented Mar 27, 2016

    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.

    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Mar 27, 2016

    Ah, the bit about csv module doing it's own newline handling is what I missed. Here is the updated patch.

    @serhiy-storchaka
    Copy link
    Member

    When this error is triggered at all?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jan 6, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    2 participants