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
93b5513c
Kaydet (Commit)
93b5513c
authored
May 19, 2010
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #6697: Fix a crash if a keyword contains a surrogate
üst
386fe71d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
test_getargs2.py
Lib/test/test_getargs2.py
+14
-0
getargs.c
Python/getargs.c
+9
-6
No files found.
Lib/test/test_getargs2.py
Dosyayı görüntüle @
93b5513c
...
@@ -252,24 +252,28 @@ class Keywords_TestCase(unittest.TestCase):
...
@@ -252,24 +252,28 @@ class Keywords_TestCase(unittest.TestCase):
getargs_keywords
((
1
,
2
),
3
,
(
4
,(
5
,
6
)),
(
7
,
8
,
9
),
10
),
getargs_keywords
((
1
,
2
),
3
,
(
4
,(
5
,
6
)),
(
7
,
8
,
9
),
10
),
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
)
)
def
test_mixed_args
(
self
):
def
test_mixed_args
(
self
):
# positional and keyword args
# positional and keyword args
self
.
assertEquals
(
self
.
assertEquals
(
getargs_keywords
((
1
,
2
),
3
,
(
4
,(
5
,
6
)),
arg4
=
(
7
,
8
,
9
),
arg5
=
10
),
getargs_keywords
((
1
,
2
),
3
,
(
4
,(
5
,
6
)),
arg4
=
(
7
,
8
,
9
),
arg5
=
10
),
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
)
)
def
test_keyword_args
(
self
):
def
test_keyword_args
(
self
):
# all keywords
# all keywords
self
.
assertEquals
(
self
.
assertEquals
(
getargs_keywords
(
arg1
=
(
1
,
2
),
arg2
=
3
,
arg3
=
(
4
,(
5
,
6
)),
arg4
=
(
7
,
8
,
9
),
arg5
=
10
),
getargs_keywords
(
arg1
=
(
1
,
2
),
arg2
=
3
,
arg3
=
(
4
,(
5
,
6
)),
arg4
=
(
7
,
8
,
9
),
arg5
=
10
),
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
)
)
def
test_optional_args
(
self
):
def
test_optional_args
(
self
):
# missing optional keyword args, skipping tuples
# missing optional keyword args, skipping tuples
self
.
assertEquals
(
self
.
assertEquals
(
getargs_keywords
(
arg1
=
(
1
,
2
),
arg2
=
3
,
arg5
=
10
),
getargs_keywords
(
arg1
=
(
1
,
2
),
arg2
=
3
,
arg5
=
10
),
(
1
,
2
,
3
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
10
)
(
1
,
2
,
3
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
10
)
)
)
def
test_required_args
(
self
):
def
test_required_args
(
self
):
# required arg missing
# required arg missing
try
:
try
:
...
@@ -278,6 +282,7 @@ class Keywords_TestCase(unittest.TestCase):
...
@@ -278,6 +282,7 @@ class Keywords_TestCase(unittest.TestCase):
self
.
assertEquals
(
str
(
err
),
"Required argument 'arg2' (pos 2) not found"
)
self
.
assertEquals
(
str
(
err
),
"Required argument 'arg2' (pos 2) not found"
)
else
:
else
:
self
.
fail
(
'TypeError should have been raised'
)
self
.
fail
(
'TypeError should have been raised'
)
def
test_too_many_args
(
self
):
def
test_too_many_args
(
self
):
try
:
try
:
getargs_keywords
((
1
,
2
),
3
,(
4
,(
5
,
6
)),(
7
,
8
,
9
),
10
,
111
)
getargs_keywords
((
1
,
2
),
3
,(
4
,(
5
,
6
)),(
7
,
8
,
9
),
10
,
111
)
...
@@ -285,6 +290,7 @@ class Keywords_TestCase(unittest.TestCase):
...
@@ -285,6 +290,7 @@ class Keywords_TestCase(unittest.TestCase):
self
.
assertEquals
(
str
(
err
),
"function takes at most 5 arguments (6 given)"
)
self
.
assertEquals
(
str
(
err
),
"function takes at most 5 arguments (6 given)"
)
else
:
else
:
self
.
fail
(
'TypeError should have been raised'
)
self
.
fail
(
'TypeError should have been raised'
)
def
test_invalid_keyword
(
self
):
def
test_invalid_keyword
(
self
):
# extraneous keyword arg
# extraneous keyword arg
try
:
try
:
...
@@ -294,6 +300,14 @@ class Keywords_TestCase(unittest.TestCase):
...
@@ -294,6 +300,14 @@ class Keywords_TestCase(unittest.TestCase):
else
:
else
:
self
.
fail
(
'TypeError should have been raised'
)
self
.
fail
(
'TypeError should have been raised'
)
def
test_surrogate_keyword
(
self
):
try
:
getargs_keywords
((
1
,
2
),
3
,
(
4
,(
5
,
6
)),
(
7
,
8
,
9
),
**
{
'
\uDC80
'
:
10
})
except
TypeError
as
err
:
self
.
assertEquals
(
str
(
err
),
"'
\udc80
' is an invalid keyword argument for this function"
)
else
:
self
.
fail
(
'TypeError should have been raised'
)
def
test_main
():
def
test_main
():
tests
=
[
Signed_TestCase
,
Unsigned_TestCase
,
Tuple_TestCase
,
Keywords_TestCase
]
tests
=
[
Signed_TestCase
,
Unsigned_TestCase
,
Tuple_TestCase
,
Keywords_TestCase
]
try
:
try
:
...
...
Python/getargs.c
Dosyayı görüntüle @
93b5513c
...
@@ -1755,18 +1755,21 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
...
@@ -1755,18 +1755,21 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
"keywords must be strings"
);
"keywords must be strings"
);
return
cleanreturn
(
0
,
freelist
);
return
cleanreturn
(
0
,
freelist
);
}
}
/* check that _PyUnicode_AsString() result is not NULL */
ks
=
_PyUnicode_AsString
(
key
);
ks
=
_PyUnicode_AsString
(
key
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
ks
!=
NULL
)
{
if
(
!
strcmp
(
ks
,
kwlist
[
i
]))
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
match
=
1
;
if
(
!
strcmp
(
ks
,
kwlist
[
i
]))
{
break
;
match
=
1
;
break
;
}
}
}
}
}
if
(
!
match
)
{
if
(
!
match
)
{
PyErr_Format
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"'%
s
' is an invalid keyword "
"'%
U
' is an invalid keyword "
"argument for this function"
,
"argument for this function"
,
k
s
);
k
ey
);
return
cleanreturn
(
0
,
freelist
);
return
cleanreturn
(
0
,
freelist
);
}
}
}
}
...
...
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