Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cac23a50
Kaydet (Commit)
cac23a50
authored
Ara 19, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
quotechar fields. Original patch by Vajrasky Kok.
üst
800e11b4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
6 deletions
+50
-6
test_csv.py
Lib/test/test_csv.py
+39
-5
NEWS
Misc/NEWS
+3
-0
_csv.c
Modules/_csv.c
+8
-1
No files found.
Lib/test/test_csv.py
Dosyayı görüntüle @
cac23a50
...
...
@@ -747,6 +747,7 @@ class TestDialectValidity(unittest.TestCase):
lineterminator
=
'
\r\n
'
quoting
=
csv
.
QUOTE_NONE
d
=
mydialect
()
self
.
assertEqual
(
d
.
quoting
,
csv
.
QUOTE_NONE
)
mydialect
.
quoting
=
None
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
...
...
@@ -755,12 +756,21 @@ class TestDialectValidity(unittest.TestCase):
mydialect
.
quoting
=
csv
.
QUOTE_ALL
mydialect
.
quotechar
=
'"'
d
=
mydialect
()
self
.
assertEqual
(
d
.
quoting
,
csv
.
QUOTE_ALL
)
self
.
assertEqual
(
d
.
quotechar
,
'"'
)
self
.
assertTrue
(
d
.
doublequote
)
mydialect
.
quotechar
=
"''"
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"quotechar" must be an 1-character string'
)
mydialect
.
quotechar
=
4
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"quotechar" must be string, not int'
)
def
test_delimiter
(
self
):
class
mydialect
(
csv
.
Dialect
):
...
...
@@ -771,12 +781,31 @@ class TestDialectValidity(unittest.TestCase):
lineterminator
=
'
\r\n
'
quoting
=
csv
.
QUOTE_NONE
d
=
mydialect
()
self
.
assertEqual
(
d
.
delimiter
,
";"
)
mydialect
.
delimiter
=
":::"
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"delimiter" must be an 1-character string'
)
mydialect
.
delimiter
=
""
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"delimiter" must be an 1-character string'
)
mydialect
.
delimiter
=
b
","
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"delimiter" must be string, not bytes'
)
mydialect
.
delimiter
=
4
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"delimiter" must be string, not int'
)
def
test_lineterminator
(
self
):
class
mydialect
(
csv
.
Dialect
):
...
...
@@ -787,12 +816,17 @@ class TestDialectValidity(unittest.TestCase):
lineterminator
=
'
\r\n
'
quoting
=
csv
.
QUOTE_NONE
d
=
mydialect
()
self
.
assertEqual
(
d
.
lineterminator
,
'
\r\n
'
)
mydialect
.
lineterminator
=
":::"
d
=
mydialect
()
self
.
assertEqual
(
d
.
lineterminator
,
":::"
)
mydialect
.
lineterminator
=
4
self
.
assertRaises
(
csv
.
Error
,
mydialect
)
with
self
.
assertRaises
(
csv
.
Error
)
as
cm
:
mydialect
()
self
.
assertEqual
(
str
(
cm
.
exception
),
'"lineterminator" must be a string'
)
class
TestSniffer
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
cac23a50
...
...
@@ -29,6 +29,9 @@ Core and Builtins
Library
-------
- Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
quotechar fields. Original patch by Vajrasky Kok.
- Issue #19855: uuid.getnode() on Unix now looks on the PATH for the
executables used to find the mac address, with /sbin and /usr/sbin as
fallbacks.
...
...
Modules/_csv.c
Dosyayı görüntüle @
cac23a50
...
...
@@ -239,6 +239,12 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt)
*
target
=
'\0'
;
if
(
src
!=
Py_None
)
{
Py_ssize_t
len
;
if
(
!
PyUnicode_Check
(
src
))
{
PyErr_Format
(
PyExc_TypeError
,
"
\"
%s
\"
must be string, not %.200s"
,
name
,
src
->
ob_type
->
tp_name
);
return
-
1
;
}
len
=
PyUnicode_GetLength
(
src
);
if
(
len
>
1
)
{
PyErr_Format
(
PyExc_TypeError
,
...
...
@@ -425,7 +431,8 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
if
(
dialect_check_quoting
(
self
->
quoting
))
goto
err
;
if
(
self
->
delimiter
==
0
)
{
PyErr_SetString
(
PyExc_TypeError
,
"delimiter must be set"
);
PyErr_SetString
(
PyExc_TypeError
,
"
\"
delimiter
\"
must be an 1-character string"
);
goto
err
;
}
if
(
quotechar
==
Py_None
&&
quoting
==
NULL
)
...
...
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