Giter VIP home page Giter VIP logo

Comments (10)

xflr6 avatar xflr6 commented on July 20, 2024

Thanks for the report.

Some of it seems to be adapting the test assertions, xfails, etc. Need to check if there is also a problem here:

csv23/csv23/writers.py

Lines 74 to 76 in 1677f82

if has_issue12178(self._writer.dialect):
self.writerow = wrapped_writerow(self.writerow,
self._writer.dialect.escapechar)

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

There is a chance that this test shows a behavioural change in Python (not sure if it would be related to the fix of https://bugs.python.org/issue12178):

In [1]: import csv
   ...: 
   ...: csv.QUOTE_MINIMAL
Out[1]: 0
>       assert line == expected * n
E       assert 'spam\\\\eggs...m\\\\eggs\r\n' == '"spam\\\\egg...\\\\eggs"\r\n'
E         - "spam\\eggs"
E         ? -          -
E         + spam\\eggs

https://docs.python.org/3/library/csv.html#csv.QUOTE_MINIMAL

Instructs writer objects to only quote those fields which contain special characters such as delimiter,
quotechar or any of the characters in lineterminator

from csv23.

mgorny avatar mgorny commented on July 20, 2024

Since csv23 is now a dependency of pip, this is quite a blocker for py3.10 porting in Gentoo. Could you tell me whether the test failures are ok to ignore for now (i.e. the new output is still valid, just different)?

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Since csv23 is now a dependency of pip, this is quite a blocker for py3.10 porting in Gentoo.

Oh, that woud be news to me: cannot find this in pip's setup.py, do you maybe have a reference for this?

from csv23.

mgorny avatar mgorny commented on July 20, 2024

Ah, they've removed it!

commit 36602b7977adff2a7d123bb273307d1cd099257e
Merge: 609d9d4a6 3cfb0ca1e
Author: Pradyun Gedam <[email protected]>
Date:   2020-12-27 18:05:54 +0100

    Merge pull request #9374 from jdufresne/csv23
    
    Drop csv23 and enum34 in favor of stdlib

Thanks for checking! This means I've got a stale dependency and can forget about this problem for the time being ;-).

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Reproduced adding Python 3.10.0-beta to test matrix.

https://github.com/xflr6/csv23/runs/3059197134?check_suite_focus=true

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Okay, looks like this is about adapting the test branches to reflect the upstream fix.

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Fixed the test logic in 30b9c95.

Remaining 7 failiures are an undocumented behavioural change AFAIU.

Reported in https://bugs.python.org/issue12178#msg397440 as follows:

Python 3.9 quotes values with escapechar:

import csv
import io

kwargs = {'escapechar': '\\'}

value = 'spam\\eggs'

print(value)

with io.StringIO() as buf:
    writer = csv.writer(buf, **kwargs)
    writer.writerow([value])
    line = buf.getvalue()

print(line.strip())

with io.StringIO(line) as buf:
    reader = csv.reader(buf, **kwargs)
    (new_value,), = reader

print(new_value)
spam\eggs
"spam\eggs"
spameggs

https://docs.python.org/3/library/csv.html#csv.QUOTE_MINIMAL

only quote those fields which contain special characters
such as delimiter, quotechar or any of the characters in lineterminator.

This seems incorrect because escapechar is not mentioned (but at the same time it says 'such as') and maybe better matching the name 'minimal' (or one might expect 'more' quoting as a better default).

Python 3.10:

https://github.com/python/cpython/blob/5c0eed7375fdd791cc5e19ceabfab4170ad44062/Lib/test/test_csv.py#L207-L208

See also https://github.com/xflr6/csv23/actions/runs/1027687524

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Adapted the test expectations in 8d56b3a, fixed assertion in 1a882a0, and demoted to note in e96ee9c.

Closing for now, pending upstream answer.

from csv23.

xflr6 avatar xflr6 commented on July 20, 2024

Opened a new upstream issue: https://bugs.python.org/issue44861

from csv23.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.