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
1df78c8e
Kaydet (Commit)
1df78c8e
authored
Mar 28, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 3.2
üst
fe557835
6a2638b1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
inspect.py
Lib/inspect.py
+8
-2
test_inspect.py
Lib/test/test_inspect.py
+33
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
1df78c8e
...
...
@@ -944,8 +944,14 @@ def getcallargs(func, *positional, **named):
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
:
raise
TypeError
(
'
%
s() takes no arguments (
%
d given)'
%
(
f_name
,
num_total
))
if
varkw
or
kwonlyargs
:
if
num_pos
:
# XXX: We should use num_pos, but Python also uses num_total:
raise
TypeError
(
'
%
s() takes exactly 0 positional arguments '
'(
%
d given)'
%
(
f_name
,
num_total
))
else
:
raise
TypeError
(
'
%
s() takes no arguments (
%
d given)'
%
(
f_name
,
num_total
))
for
arg
in
itertools
.
chain
(
args
,
kwonlyargs
):
if
arg
in
named
:
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
1df78c8e
...
...
@@ -632,6 +632,16 @@ class TestGetcallargsFunctions(unittest.TestCase):
self
.
assertEqualCallArgs
(
f
,
'2, c=4, **collections.UserDict(b=3)'
)
self
.
assertEqualCallArgs
(
f
,
'b=2, **collections.UserDict(a=3, c=4)'
)
def
test_varkw_only
(
self
):
# issue11256:
f
=
self
.
makeCallable
(
'**c'
)
self
.
assertEqualCallArgs
(
f
,
''
)
self
.
assertEqualCallArgs
(
f
,
'a=1'
)
self
.
assertEqualCallArgs
(
f
,
'a=1, b=2'
)
self
.
assertEqualCallArgs
(
f
,
'c=3, **{"a": 1, "b": 2}'
)
self
.
assertEqualCallArgs
(
f
,
'**collections.UserDict(a=1, b=2)'
)
self
.
assertEqualCallArgs
(
f
,
'c=3, **collections.UserDict(a=1, b=2)'
)
def
test_keyword_only
(
self
):
f
=
self
.
makeCallable
(
'a=3, *, c, d=2'
)
self
.
assertEqualCallArgs
(
f
,
'c=3'
)
...
...
@@ -643,6 +653,11 @@ class TestGetcallargsFunctions(unittest.TestCase):
self
.
assertEqualException
(
f
,
'a=3'
)
self
.
assertEqualException
(
f
,
'd=4'
)
f
=
self
.
makeCallable
(
'*, c, d=2'
)
self
.
assertEqualCallArgs
(
f
,
'c=3'
)
self
.
assertEqualCallArgs
(
f
,
'c=3, d=4'
)
self
.
assertEqualCallArgs
(
f
,
'd=4, c=3'
)
def
test_multiple_features
(
self
):
f
=
self
.
makeCallable
(
'a, b=2, *f, **g'
)
self
.
assertEqualCallArgs
(
f
,
'2, 3, 7'
)
...
...
@@ -656,6 +671,17 @@ class TestGetcallargsFunctions(unittest.TestCase):
'(4,[5,6])]), **collections.UserDict('
'y=9, z=10)'
)
f
=
self
.
makeCallable
(
'a, b=2, *f, x, y=99, **g'
)
self
.
assertEqualCallArgs
(
f
,
'2, 3, x=8'
)
self
.
assertEqualCallArgs
(
f
,
'2, 3, x=8, *[(4,[5,6]), 7]'
)
self
.
assertEqualCallArgs
(
f
,
'2, x=8, *[3, (4,[5,6]), 7], y=9, z=10'
)
self
.
assertEqualCallArgs
(
f
,
'x=8, *[2, 3, (4,[5,6])], y=9, z=10'
)
self
.
assertEqualCallArgs
(
f
,
'x=8, *collections.UserList('
'[2, 3, (4,[5,6])]), q=0, **{"y":9, "z":10}'
)
self
.
assertEqualCallArgs
(
f
,
'2, x=8, *collections.UserList([3, '
'(4,[5,6])]), q=0, **collections.UserDict('
'y=9, z=10)'
)
def
test_errors
(
self
):
f0
=
self
.
makeCallable
(
''
)
f1
=
self
.
makeCallable
(
'a, b'
)
...
...
@@ -692,6 +718,13 @@ class TestGetcallargsFunctions(unittest.TestCase):
# - for functions and bound methods: unexpected keyword 'c'
# - for unbound methods: multiple values for keyword 'a'
#self.assertEqualException(f, '1, c=3, a=2')
# issue11256:
f3
=
self
.
makeCallable
(
'**c'
)
self
.
assertEqualException
(
f3
,
'1, 2'
)
self
.
assertEqualException
(
f3
,
'1, 2, a=1, b=2'
)
f4
=
self
.
makeCallable
(
'*, a, b=0'
)
self
.
assertEqualException
(
f3
,
'1, 2'
)
self
.
assertEqualException
(
f3
,
'1, 2, a=1, b=2'
)
class
TestGetcallargsMethods
(
TestGetcallargsFunctions
):
...
...
Misc/NEWS
Dosyayı görüntüle @
1df78c8e
...
...
@@ -87,6 +87,9 @@ Core and Builtins
Library
-------
-
Issue
#
11256
:
Fix
inspect
.
getcallargs
on
functions
that
take
only
keyword
arguments
.
-
Issue
#
11696
:
Fix
ID
generation
in
msilib
.
-
itertools
.
accumulate
now
supports
an
optional
*
func
*
argument
for
...
...
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