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
6326278e
Kaydet (Commit)
6326278e
authored
Ara 21, 2018
tarafından
Xtreak
Kaydeden (comit)
Serhiy Storchaka
Ara 21, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34193: Fix pluralization in getargs.c and test cases. (GH-8438)
üst
3e8f962e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
23 deletions
+38
-23
test_call.py
Lib/test/test_call.py
+7
-4
test_getargs2.py
Lib/test/test_getargs2.py
+4
-4
2018-07-24-11-57-35.bpo-34193.M6ch1Q.rst
...EWS.d/next/C API/2018-07-24-11-57-35.bpo-34193.M6ch1Q.rst
+2
-0
typeobject.c
Objects/typeobject.c
+1
-1
getargs.c
Python/getargs.c
+24
-14
No files found.
Lib/test/test_call.py
Dosyayı görüntüle @
6326278e
...
...
@@ -160,19 +160,22 @@ class CFunctionCallsErrorMessages(unittest.TestCase):
msg
=
r"^from_bytes\(\) takes at most 2 positional arguments \(3 given\)"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
int
.
from_bytes
,
b
'a'
,
'little'
,
False
)
def
test_varargs
4
(
self
):
def
test_varargs
1min
(
self
):
msg
=
r"get expected at least 1 argument, got 0"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
{}
.
get
)
def
test_varargs5
(
self
):
msg
=
r"expected 1 argument, got 0"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
{}
.
__delattr__
)
def
test_varargs2min
(
self
):
msg
=
r"getattr expected at least 2 arguments, got 0"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
getattr
)
def
test_varargs
6
(
self
):
def
test_varargs
1max
(
self
):
msg
=
r"input expected at most 1 argument, got 2"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
input
,
1
,
2
)
def
test_varargs
7
(
self
):
def
test_varargs
2max
(
self
):
msg
=
r"get expected at most 2 arguments, got 3"
self
.
assertRaisesRegex
(
TypeError
,
msg
,
{}
.
get
,
1
,
2
,
3
)
...
...
Lib/test/test_getargs2.py
Dosyayı görüntüle @
6326278e
...
...
@@ -682,11 +682,11 @@ class PositionalOnlyAndKeywords_TestCase(unittest.TestCase):
self
.
assertEqual
(
self
.
getargs
(
1
),
(
1
,
-
1
,
-
1
))
# required positional arg missing
with
self
.
assertRaisesRegex
(
TypeError
,
r"function takes at least 1 positional argument
s
\(0 given\)"
):
r"function takes at least 1 positional argument \(0 given\)"
):
self
.
getargs
()
with
self
.
assertRaisesRegex
(
TypeError
,
r"function takes at least 1 positional argument
s
\(0 given\)"
):
r"function takes at least 1 positional argument \(0 given\)"
):
self
.
getargs
(
keyword
=
3
)
def
test_empty_keyword
(
self
):
...
...
@@ -1112,7 +1112,7 @@ class ParseTupleAndKeywords_Test(unittest.TestCase):
parse
((
1
,),
{
'a'
:
3
},
'OOO'
,
[
''
,
''
,
'a'
])
parse
((
1
,),
{},
'O|OO'
,
[
''
,
''
,
'a'
])
with
self
.
assertRaisesRegex
(
TypeError
,
r'function takes at least 1 positional argument
s
\(0 given\)'
):
r'function takes at least 1 positional argument \(0 given\)'
):
parse
((),
{},
'O|OO'
,
[
''
,
''
,
'a'
])
parse
((
1
,
2
),
{
'a'
:
3
},
'OO$O'
,
[
''
,
''
,
'a'
])
with
self
.
assertRaisesRegex
(
TypeError
,
...
...
@@ -1120,7 +1120,7 @@ class ParseTupleAndKeywords_Test(unittest.TestCase):
parse
((
1
,),
{
'a'
:
3
},
'OO$O'
,
[
''
,
''
,
'a'
])
parse
((
1
,),
{},
'O|O$O'
,
[
''
,
''
,
'a'
])
with
self
.
assertRaisesRegex
(
TypeError
,
r'function takes at least 1 positional argument
s
\(0 given\)'
):
r'function takes at least 1 positional argument \(0 given\)'
):
parse
((),
{},
'O|O$O'
,
[
''
,
''
,
'a'
])
with
self
.
assertRaisesRegex
(
SystemError
,
r'Empty parameter name after \$'
):
parse
((
1
,),
{},
'O|$OO'
,
[
''
,
''
,
'a'
])
...
...
Misc/NEWS.d/next/C API/2018-07-24-11-57-35.bpo-34193.M6ch1Q.rst
0 → 100644
Dosyayı görüntüle @
6326278e
Fix pluralization in TypeError messages in getargs.c and typeobject.c:
'1 argument' instead of '1 arguments' and '1 element' instead of '1 elements'.
Objects/typeobject.c
Dosyayı görüntüle @
6326278e
...
...
@@ -5434,7 +5434,7 @@ check_num_args(PyObject *ob, int n)
return
1
;
PyErr_Format
(
PyExc_TypeError
,
"expected %d argument
s, got %zd"
,
n
,
PyTuple_GET_SIZE
(
ob
));
"expected %d argument
%s, got %zd"
,
n
,
n
==
1
?
""
:
"s"
,
PyTuple_GET_SIZE
(
ob
));
return
0
;
}
...
...
Python/getargs.c
Dosyayı görüntüle @
6326278e
...
...
@@ -540,8 +540,10 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
levels
[
0
]
=
0
;
if
(
toplevel
)
{
PyOS_snprintf
(
msgbuf
,
bufsize
,
"expected %d arguments, not %"
PY_FORMAT_SIZE_T
"d"
,
n
,
len
);
"expected %d argument%s, not %"
PY_FORMAT_SIZE_T
"d"
,
n
,
n
==
1
?
""
:
"s"
,
len
);
}
else
{
PyOS_snprintf
(
msgbuf
,
bufsize
,
...
...
@@ -1718,12 +1720,14 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"%.200s%s takes %s %d positional arguments"
"%.200s%s takes %s %d positional argument
%
s"
" (%d given)"
,
(
fname
==
NULL
)
?
"function"
:
fname
,
(
fname
==
NULL
)
?
""
:
"()"
,
(
min
!=
INT_MAX
)
?
"at most"
:
"exactly"
,
max
,
nargs
);
max
,
max
==
1
?
""
:
"s"
,
nargs
);
}
return
cleanreturn
(
0
,
&
freelist
);
}
...
...
@@ -1797,12 +1801,14 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
if
(
skip
)
{
PyErr_Format
(
PyExc_TypeError
,
"%.200s%s takes %s %d positional arguments"
"%.200s%s takes %s %d positional argument
%
s"
" (%d given)"
,
(
fname
==
NULL
)
?
"function"
:
fname
,
(
fname
==
NULL
)
?
""
:
"()"
,
(
Py_MIN
(
pos
,
min
)
<
i
)
?
"at least"
:
"exactly"
,
Py_MIN
(
pos
,
min
),
nargs
);
Py_MIN
(
pos
,
min
),
Py_MIN
(
pos
,
min
)
==
1
?
""
:
"s"
,
nargs
);
return
cleanreturn
(
0
,
&
freelist
);
}
...
...
@@ -2104,11 +2110,13 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"%.200s%s takes %s %d positional arguments (%d given)"
,
"%.200s%s takes %s %d positional argument
%
s (%d given)"
,
(
parser
->
fname
==
NULL
)
?
"function"
:
parser
->
fname
,
(
parser
->
fname
==
NULL
)
?
""
:
"()"
,
(
parser
->
min
!=
INT_MAX
)
?
"at most"
:
"exactly"
,
parser
->
max
,
nargs
);
parser
->
max
,
parser
->
max
==
1
?
""
:
"s"
,
nargs
);
}
return
cleanreturn
(
0
,
&
freelist
);
}
...
...
@@ -2152,12 +2160,14 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
if
(
i
<
pos
)
{
Py_ssize_t
min
=
Py_MIN
(
pos
,
parser
->
min
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s%s takes %s %d positional arguments"
"%.200s%s takes %s %d positional argument
%
s"
" (%d given)"
,
(
parser
->
fname
==
NULL
)
?
"function"
:
parser
->
fname
,
(
parser
->
fname
==
NULL
)
?
""
:
"()"
,
min
<
parser
->
max
?
"at least"
:
"exactly"
,
min
,
nargs
);
min
,
min
==
1
?
""
:
"s"
,
nargs
);
}
else
{
keyword
=
PyTuple_GET_ITEM
(
kwtuple
,
i
-
pos
);
...
...
@@ -2417,9 +2427,9 @@ unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
else
PyErr_Format
(
PyExc_TypeError
,
"unpacked tuple should have %s%zd elements,"
"unpacked tuple should have %s%zd element
%
s,"
" but has %zd"
,
(
min
==
max
?
""
:
"at least "
),
min
,
nargs
);
(
min
==
max
?
""
:
"at least "
),
min
,
min
==
1
?
""
:
"s"
,
nargs
);
return
0
;
}
...
...
@@ -2436,9 +2446,9 @@ unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
else
PyErr_Format
(
PyExc_TypeError
,
"unpacked tuple should have %s%zd elements,"
"unpacked tuple should have %s%zd element
%
s,"
" but has %zd"
,
(
min
==
max
?
""
:
"at most "
),
max
,
nargs
);
(
min
==
max
?
""
:
"at most "
),
max
,
max
==
1
?
""
:
"s"
,
nargs
);
return
0
;
}
...
...
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