New submission from Thibault Kruse: To reproduce
$ python --version Python 2.7.3 $ python -c 'from __future__ import unicode_literals; import csv; reader = csv.reader("foo", delimiter=",")' Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: "delimiter" must be an 1-character string This is confusing because "," is like a 1-character (unicode) string, while csv requires a 1-character (byte) string. In python3, it's the inverse problem, using bytestring b',' $ python3 --version Python 3.2.3 $ python3 -c 'import csv; reader = csv.reader("foo", delimiter=b",")' Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: "delimiter" must be an 1-character string So I believe csv should state more clearly what went wrong here in each case, or what kind of string csv is willing to accept in the respective python version. Whether the python3 refusal to use a bytestring is even reasonable I don't know. This might or might not be related to the issue of multichar delimiters: http://bugs.python.org/issue15158 (just sayin) ---------- components: Library (Lib) messages: 196126 nosy: Thibault.Kruse priority: normal severity: normal status: open title: csv produces confusing error message for unexpected string encoding type: behavior versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18829> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com