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
88968ad3
Kaydet (Commit)
88968ad3
authored
Haz 25, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
only take into account positional arguments count in related error messages
üst
5a3ef5b2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
6 deletions
+16
-6
inspect.py
Lib/inspect.py
+1
-1
test_extcall.py
Lib/test/test_extcall.py
+2
-2
test_keywordonlyarg.py
Lib/test/test_keywordonlyarg.py
+8
-0
NEWS
Misc/NEWS
+2
-0
ceval.c
Python/ceval.c
+3
-3
No files found.
Lib/inspect.py
Dosyayı görüntüle @
88968ad3
...
...
@@ -959,7 +959,7 @@ def getcallargs(func, *positional, **named):
else
:
arg2value
[
varargs
]
=
()
elif
0
<
num_args
<
num_pos
:
raise
TypeError
(
'
%
s() takes
%
s
%
d
%
s (
%
d given)'
%
(
raise
TypeError
(
'
%
s() takes
%
s
%
d
positional
%
s (
%
d given)'
%
(
f_name
,
'at most'
if
defaults
else
'exactly'
,
num_args
,
'arguments'
if
num_args
>
1
else
'argument'
,
num_total
))
elif
num_args
==
0
and
num_total
:
...
...
Lib/test/test_extcall.py
Dosyayı görüntüle @
88968ad3
...
...
@@ -279,13 +279,13 @@ The number of arguments passed in includes keywords:
>>> f(6, a=4, *(1, 2, 3))
Traceback (most recent call last):
...
TypeError: f() takes exactly 1 argument (5 given)
TypeError: f() takes exactly 1
positional
argument (5 given)
>>> def f(a, *, kw):
... pass
>>> f(6, 4, kw=4)
Traceback (most recent call last):
...
TypeError: f() takes exactly
2 arguments
(3 given)
TypeError: f() takes exactly
1 positional argument
(3 given)
"""
import
sys
...
...
Lib/test/test_keywordonlyarg.py
Dosyayı görüntüle @
88968ad3
...
...
@@ -73,6 +73,14 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
fundef3
+=
"lastarg):
\n
pass
\n
"
compile
(
fundef3
,
"<test>"
,
"single"
)
def
testTooManyPositionalErrorMessage
(
self
):
def
f
(
a
,
b
=
None
,
*
,
c
=
None
):
pass
with
self
.
assertRaises
(
TypeError
)
as
exc
:
f
(
1
,
2
,
3
)
expected
=
"f() takes at most 2 positional arguments (3 given)"
self
.
assertEqual
(
str
(
exc
.
exception
),
expected
)
def
testSyntaxErrorForFunctionCall
(
self
):
self
.
assertRaisesSyntaxError
(
"f(p, k=1, p2)"
)
self
.
assertRaisesSyntaxError
(
"f(p, k1=50, *(1,2), k1=100)"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
88968ad3
...
...
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
- Be more specific in error messages about positional arguments.
- Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
objects, as described in the documentation.
...
...
Python/ceval.c
Dosyayı görüntüle @
88968ad3
...
...
@@ -3100,11 +3100,11 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
if
(
!
(
co
->
co_flags
&
CO_VARARGS
))
{
PyErr_Format
(
PyExc_TypeError
,
"%U() takes %s %d "
"argument%s (%d given)"
,
"
positional
argument%s (%d given)"
,
co
->
co_name
,
defcount
?
"at most"
:
"exactly"
,
total_args
,
total_args
==
1
?
""
:
"s"
,
co
->
co_argcount
,
co
->
co_argcount
==
1
?
""
:
"s"
,
argcount
+
kwcount
);
goto
fail
;
}
...
...
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