New submission from Thomas Lotze:

A csv.writer with quoting=csv.QUOTE_NONNUMERIC does not quote boolean values, 
which makes a csv.reader with the same quoting behaviour fail on that value:

-------- csv.py ----------

import csv
import io


f = io.StringIO()

writer = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
writer.writerow(['asdf', 1, True])

f.seek(0)
reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
for row in reader:
    print(row)

----------------------

$ python3 csvbug.py 
Traceback (most recent call last):
  File "csvbug.py", line 12, in <module>
    for row in reader:
ValueError: could not convert string to float: 'True'

----------------------

I'd consider this inconsistency a bug, but in any case something that needs 
documenting.

----------
components: Library (Lib)
messages: 291516
nosy: tlotze
priority: normal
severity: normal
status: open
title: csv: Inconsistency re QUOTE_NONNUMERIC
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30046>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to