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
021bb878
Kaydet (Commit)
021bb878
authored
Ock 25, 2014
tarafından
Zachary Ware
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20381: Fix sanity checking on default arguments when c_default is
also specified.
üst
66964cd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
NEWS
Misc/NEWS
+5
-0
clinic.py
Tools/clinic/clinic.py
+11
-3
No files found.
Misc/NEWS
Dosyayı görüntüle @
021bb878
...
@@ -141,6 +141,11 @@ Tests
...
@@ -141,6 +141,11 @@ Tests
Tools/Demos
Tools/Demos
-----------
-----------
- Issue #20381: Argument Clinic now sanity checks the default argument when
c_default is also specified, providing a nice failure message for
disallowed values.
- Issue #20189: Argument Clinic now ensures that parser functions for
- Issue #20189: Argument Clinic now ensures that parser functions for
__new__ are always of type newfunc, the type of the tp_new slot.
__new__ are always of type newfunc, the type of the tp_new slot.
Similarly, parser functions for __init__ are now always of type initproc,
Similarly, parser functions for __init__ are now always of type initproc,
...
...
Tools/clinic/clinic.py
Dosyayı görüntüle @
021bb878
...
@@ -3279,11 +3279,11 @@ class DSLParser:
...
@@ -3279,11 +3279,11 @@ class DSLParser:
fail
(
"You can't specify py_default without specifying a default value!"
)
fail
(
"You can't specify py_default without specifying a default value!"
)
else
:
else
:
default
=
default
.
strip
()
default
=
default
.
strip
()
bad
=
False
ast_input
=
"x = {}"
.
format
(
default
)
ast_input
=
"x = {}"
.
format
(
default
)
try
:
try
:
module
=
ast
.
parse
(
ast_input
)
module
=
ast
.
parse
(
ast_input
)
bad
=
False
if
'c_default'
not
in
kwargs
:
if
'c_default'
not
in
kwargs
:
# we can only represent very simple data values in C.
# we can only represent very simple data values in C.
# detect whether default is okay, via a blacklist
# detect whether default is okay, via a blacklist
...
@@ -3317,8 +3317,16 @@ class DSLParser:
...
@@ -3317,8 +3317,16 @@ class DSLParser:
bad
=
blacklist
.
bad
bad
=
blacklist
.
bad
else
:
else
:
# if they specify a c_default, we can be more lenient about the default value.
# if they specify a c_default, we can be more lenient about the default value.
# but at least ensure that we can turn it into text and reconstitute it correctly.
# but at least make an attempt at ensuring it's a valid expression.
bad
=
default
!=
repr
(
eval
(
default
))
try
:
value
=
eval
(
default
)
if
value
==
unspecified
:
fail
(
"'unspecified' is not a legal default value!"
)
except
NameError
:
pass
# probably a named constant
except
Exception
as
e
:
fail
(
"Malformed expression given as default value
\n
"
"{!r} caused {!r}"
.
format
(
default
,
e
))
if
bad
:
if
bad
:
fail
(
"Unsupported expression as default value: "
+
repr
(
default
))
fail
(
"Unsupported expression as default value: "
+
repr
(
default
))
...
...
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