Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7e049e4f
Commit
7e049e4f
authored
Sep 25, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka.
parent
3e95ebcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
Lib/test/test_csv.py
Lib/test/test_csv.py
+9
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_csv.c
Modules/_csv.c
+7
-3
No files found.
Lib/test/test_csv.py
View file @
7e049e4f
...
...
@@ -225,6 +225,15 @@ class Test_Csv(unittest.TestCase):
self
.
assertRaises
(
csv
.
Error
,
self
.
_read_test
,
[
'a,b
\
n
c,d'
],
[])
self
.
assertRaises
(
csv
.
Error
,
self
.
_read_test
,
[
'a,b
\
r
\
n
c,d'
],
[])
def
test_read_eof
(
self
):
self
.
_read_test
([
'a,"'
],
[[
'a'
,
''
]])
self
.
_read_test
([
'"a'
],
[[
'a'
]])
self
.
_read_test
([
'^'
],
[[
'
\
n
'
]],
escapechar
=
'^'
)
self
.
assertRaises
(
csv
.
Error
,
self
.
_read_test
,
[
'a,"'
],
[],
strict
=
True
)
self
.
assertRaises
(
csv
.
Error
,
self
.
_read_test
,
[
'"a'
],
[],
strict
=
True
)
self
.
assertRaises
(
csv
.
Error
,
self
.
_read_test
,
[
'^'
],
[],
escapechar
=
'^'
,
strict
=
True
)
def
test_read_escape
(
self
):
self
.
_read_test
([
'a,
\
\
b,c'
],
[[
'a'
,
'b'
,
'c'
]],
escapechar
=
'
\
\
'
)
self
.
_read_test
([
'a,b
\
\
,c'
],
[[
'a'
,
'b,c'
]],
escapechar
=
'
\
\
'
)
...
...
Misc/NEWS
View file @
7e049e4f
...
...
@@ -123,6 +123,9 @@ Core and Builtins
Library
-------
- Issue #16013: Fix CSV Reader parsing issue with ending quote characters.
Patch by Serhiy Storchaka.
- Issue #15421: fix an OverflowError in Calendar.itermonthdates() after
datetime.MAXYEAR. Patch by Cédric Krier.
...
...
Modules/_csv.c
View file @
7e049e4f
...
...
@@ -759,9 +759,13 @@ Reader_iternext(ReaderObj *self)
lineobj
=
PyIter_Next
(
self
->
input_iter
);
if
(
lineobj
==
NULL
)
{
/* End of input OR exception */
if
(
!
PyErr_Occurred
()
&&
self
->
field_len
!=
0
)
PyErr_Format
(
error_obj
,
"newline inside string"
);
if
(
!
PyErr_Occurred
()
&&
(
self
->
field_len
!=
0
||
self
->
state
==
IN_QUOTED_FIELD
))
{
if
(
self
->
dialect
->
strict
)
PyErr_SetString
(
error_obj
,
"unexpected end of data"
);
else
if
(
parse_save_field
(
self
)
>=
0
)
break
;
}
return
NULL
;
}
if
(
!
PyUnicode_Check
(
lineobj
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment