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
test_csv struni fixes + unicode support in _csv #45275
Comments
This patch fixes test_csv.py for the struni branch and modifies _csv.c to support unicode strings. Changes:
All tests are now passing on my system (linux). |
Adam, I've spent some time looking at this patch. Bear in mind this is my first foray into Py3k. Still, I'm confused about what's going on here. I'm hoping you can help me understand the changes. In parse_save_field, you replaced PyString_FromStringAndSize with PyUnicode_FromUnicode, however in get_nullchar_as_None you replaced it with PyUnicode_DecodeASCII. When I execute the csv tests there are a number of assertion errors related to the default delimiter. The traceback goes something like this: FAIL: test_writer_kw_attrs (main.Test_Csv) Traceback (most recent call last):
File "Lib/test/test_csv.py", line 88, in test_writer_kw_attrs
self._test_kw_attrs(csv.writer, StringIO())
File "Lib/test/test_csv.py", line 75, in _test_kw_attrs
self.assertEqual(obj.dialect.delimiter, ':')
AssertionError: s'\x00' != ':' Any idea how to solve that? It looks to me like some Unicode buffer might be getting interpreted as a char *, but I'm not sure. Skip |
Skip, static PyObject *
get_nullchar_as_None(Py_UNICODE c)
{
if (c == '\0') {
Py_INCREF(Py_None);
return Py_None;
}
else
return PyUnicode_FromUnicode((Py_UNICODE*)&c, 1);
} Unfortunately I'm on the road right now so I can't test it. Is there something I need to do with my build to trigger those assertions? I didn't see them. |
This looked good enough to submit. Committed revision 56777. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: