mirror of https://github.com/python/cpython
[3.13] gh-113785: csv: fields starting with escapechar are not quoted (GH-122110) (GH-122258)
(cherry picked from commit a3327dbfd4
)
Co-authored-by: Mikołaj Kuranowski <mkuranowski@gmail.com>
This commit is contained in:
parent
94db4cc5e6
commit
6933c4ace9
|
@ -454,6 +454,10 @@ class Test_Csv(unittest.TestCase):
|
|||
quoting=csv.QUOTE_STRINGS)
|
||||
self._read_test(['1,@,3,@,5'], [['1', ',3,', '5']], quotechar='@')
|
||||
self._read_test(['1,\0,3,\0,5'], [['1', ',3,', '5']], quotechar='\0')
|
||||
self._read_test(['1\\.5,\\.5,.5'], [[1.5, 0.5, 0.5]],
|
||||
quoting=csv.QUOTE_NONNUMERIC, escapechar='\\')
|
||||
self._read_test(['1\\.5,\\.5,"\\.5"'], [[1.5, 0.5, ".5"]],
|
||||
quoting=csv.QUOTE_STRINGS, escapechar='\\')
|
||||
|
||||
def test_read_skipinitialspace(self):
|
||||
self._read_test(['no space, space, spaces,\ttab'],
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
:mod:`csv` now correctly parses numeric fields (when used with :const:`csv.QUOTE_NONNUMERIC` or :const:`csv.QUOTE_STRINGS`) which start with an escape character.
|
|
@ -749,7 +749,6 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
|
|||
}
|
||||
else if (c == dialect->escapechar) {
|
||||
/* possible escaped character */
|
||||
self->unquoted_field = false;
|
||||
self->state = ESCAPED_CHAR;
|
||||
}
|
||||
else if (c == ' ' && dialect->skipinitialspace)
|
||||
|
|
Loading…
Reference in New Issue