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
77d46607
Kaydet (Commit)
77d46607
authored
Mar 28, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Correct handling of functions with only kwarg args in getcallargs (closes #11256)
A patch from Daniel Urban.
üst
41a9ec90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
inspect.py
Lib/inspect.py
+8
-2
test_inspect.py
Lib/test/test_inspect.py
+14
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
77d46607
...
@@ -943,8 +943,14 @@ def getcallargs(func, *positional, **named):
...
@@ -943,8 +943,14 @@ def getcallargs(func, *positional, **named):
f_name
,
'at most'
if
defaults
else
'exactly'
,
num_args
,
f_name
,
'at most'
if
defaults
else
'exactly'
,
num_args
,
'arguments'
if
num_args
>
1
else
'argument'
,
num_total
))
'arguments'
if
num_args
>
1
else
'argument'
,
num_total
))
elif
num_args
==
0
and
num_total
:
elif
num_args
==
0
and
num_total
:
raise
TypeError
(
'
%
s() takes no arguments (
%
d given)'
%
if
varkw
:
(
f_name
,
num_total
))
if
num_pos
:
# XXX: We should use num_pos, but Python also uses num_total:
raise
TypeError
(
'
%
s() takes exactly 0 arguments '
'(
%
d given)'
%
(
f_name
,
num_total
))
else
:
raise
TypeError
(
'
%
s() takes no arguments (
%
d given)'
%
(
f_name
,
num_total
))
for
arg
in
args
:
for
arg
in
args
:
if
isinstance
(
arg
,
str
)
and
arg
in
named
:
if
isinstance
(
arg
,
str
)
and
arg
in
named
:
if
is_assigned
(
arg
):
if
is_assigned
(
arg
):
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
77d46607
...
@@ -632,6 +632,16 @@ class TestGetcallargsFunctions(unittest.TestCase):
...
@@ -632,6 +632,16 @@ class TestGetcallargsFunctions(unittest.TestCase):
self
.
assertEqualCallArgs
(
f
,
'2, c=4, **{u"b":3}'
)
self
.
assertEqualCallArgs
(
f
,
'2, c=4, **{u"b":3}'
)
self
.
assertEqualCallArgs
(
f
,
'b=2, **{u"a":3, u"c":4}'
)
self
.
assertEqualCallArgs
(
f
,
'b=2, **{u"a":3, u"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
,
'**UserDict(a=1, b=2)'
)
self
.
assertEqualCallArgs
(
f
,
'c=3, **UserDict(a=1, b=2)'
)
def
test_tupleargs
(
self
):
def
test_tupleargs
(
self
):
f
=
self
.
makeCallable
(
'(b,c), (d,(e,f))=(0,[1,2])'
)
f
=
self
.
makeCallable
(
'(b,c), (d,(e,f))=(0,[1,2])'
)
self
.
assertEqualCallArgs
(
f
,
'(2,3)'
)
self
.
assertEqualCallArgs
(
f
,
'(2,3)'
)
...
@@ -693,6 +703,10 @@ class TestGetcallargsFunctions(unittest.TestCase):
...
@@ -693,6 +703,10 @@ class TestGetcallargsFunctions(unittest.TestCase):
self
.
assertEqualException
(
f
,
'1'
)
self
.
assertEqualException
(
f
,
'1'
)
self
.
assertEqualException
(
f
,
'[1]'
)
self
.
assertEqualException
(
f
,
'[1]'
)
self
.
assertEqualException
(
f
,
'(1,2,3)'
)
self
.
assertEqualException
(
f
,
'(1,2,3)'
)
# issue11256:
f3
=
self
.
makeCallable
(
'**c'
)
self
.
assertEqualException
(
f3
,
'1, 2'
)
self
.
assertEqualException
(
f3
,
'1, 2, a=1, b=2'
)
class
TestGetcallargsMethods
(
TestGetcallargsFunctions
):
class
TestGetcallargsMethods
(
TestGetcallargsFunctions
):
...
...
Misc/NEWS
Dosyayı görüntüle @
77d46607
...
@@ -47,6 +47,9 @@ Core and Builtins
...
@@ -47,6 +47,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
arguments.
- Issue #11696: Fix ID generation in msilib.
- Issue #11696: Fix ID generation in msilib.
- Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
- Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when
...
...
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