[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-12 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset ce5a3cd9b15c9379753aefabd696bff11495cbbb by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
bpo-32255: Always quote a single empty field when write into a CSV file. 
(GH-4769) (#4810)
https://github.com/python/cpython/commit/ce5a3cd9b15c9379753aefabd696bff11495cbbb


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Thank you for your contribution Licht!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-12 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 2001900b0c02a397d8cf1d776a7cc7fcb2a463e3 by Serhiy Storchaka 
(Licht Takeuchi) in branch 'master':
bpo-32255: Always quote a single empty field when write into a CSV file. (#4769)
https://github.com/python/cpython/commit/2001900b0c02a397d8cf1d776a7cc7fcb2a463e3


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-12 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4705
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-11 Thread Licht Takeuchi

Licht Takeuchi  added the comment:

PR is now fixed so as to follow the behavior on Python 2.7!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-10 Thread Licht Takeuchi

Licht Takeuchi  added the comment:

Thanks for your investigation!
Would you mind if I create a new patch?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-10 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

For restoring the 3.4 behavior the single empty field must be quoted. This 
allows to distinguish a 1-element row with the single empty field from an empty 
row.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-10 Thread R. David Murray

R. David Murray  added the comment:

The second case is indeed the bug, as can be seen by running the examples 
against python2.7.  It looks like this was probably broken by 7901b48a1f89 from 
issue 23171.

--
components: +Library (Lib) -IO
nosy: +r.david.murray
stage: patch review -> needs patch
versions:  -Python 2.7, Python 3.4, Python 3.5, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-10 Thread R. David Murray

R. David Murray  added the comment:

Serhiy, since it was your patch that probably introduced this bug, can you take 
a look?  Obviously it isn't a very high priority bug, since no one has reported 
a problem (even this issue isn't reporting the change in behavior as a 
*problem* :)

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-09 Thread Licht Takeuchi

Licht Takeuchi  added the comment:

The current implementation does not quote in most case. IOW, the patch which 
makes all '' is quoted is the breaking change (Note that there are some 
applications does not use quoting).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-09 Thread Licht Takeuchi

Licht Takeuchi  added the comment:

I think the first one is buggy and there are two reasons.

1. The both are valid CSV. The double quoting is unnecessary. Some other 
applications, eg. Excel, does not use the double quoting.
Also, the current implementation make to quote only if the string is '' and the 
output is at the first line.

2. '' is not quoted when the two columns case.
## Input:
```
import csv
fp = open('test.csv', 'w')
w = csv.writer(fp, dialect=None)
w.writerow(['', ''])
w.writerow(['3', 'a'])
fp.close()
```
## Output:
```
,
3,a
```

These seem inconsistent and the quoting is unnecessary in this case.

# References
http://www.ietf.org/rfc/rfc4180.txt

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-09 Thread Nitish

Nitish  added the comment:

Which scenario you think is the wrong behaviour in this case? First one or 
second one?

I don't know much about csv module, but I thought it was a deliberate choice 
made to quote all empty lines and hence considered the second scenario as 
buggy. But your pull requests seems to fix the first case. Am I missing 
something here?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-09 Thread Licht Takeuchi

Change by Licht Takeuchi :


--
keywords: +patch
pull_requests: +4672
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-08 Thread Nitish

Change by Nitish :


--
nosy: +nitishch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32255] csv.writer converts None to '""\n' when it is first line, otherwise '\n'

2017-12-08 Thread Licht Takeuchi

New submission from Licht Takeuchi :

Inconsistent behavior while reading a single column CSV.
I have the patch and waiting for the CLA response.

# Case 1
## Input
```
import csv
fp = open('test.csv', 'w')
w = csv.writer(fp)
w.writerow([''])
w.writerow(['1'])
fp.close()
```
## Output
```
""
1
```

# Case 2
## Input
```
import csv
fp = open('test.csv', 'w')
w = csv.writer(fp)
w.writerow(['1'])
w.writerow([''])
fp.close()
```
## Output
```
1

```

--
components: IO
messages: 307851
nosy: licht-t
priority: normal
severity: normal
status: open
title: csv.writer converts None to '""\n' when it is first line, otherwise '\n'
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com