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
026019f8
Kaydet (Commit)
026019f8
authored
Şub 18, 2014
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Mangle __parameters in __annotations__ dict properly. Issue #20625.
üst
ee227ae7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
1 deletion
+37
-1
3.4.rst
Doc/whatsnew/3.4.rst
+4
-0
test_grammar.py
Lib/test/test_grammar.py
+7
-0
test_inspect.py
Lib/test/test_inspect.py
+16
-0
NEWS
Misc/NEWS
+3
-0
compile.c
Python/compile.c
+7
-1
No files found.
Doc/whatsnew/3.4.rst
Dosyayı görüntüle @
026019f8
...
...
@@ -1704,6 +1704,10 @@ Changes in the Python API
informative :exc:`ValueError` rather than the previous more mysterious
:exc:`AttributeError` (:issue:`9177`).
* Parameter names in ``__annotations__`` dict are now mangled properly,
similarly to ``__kwdefaults__``. (Contributed by Yury Selivanov in
:issue:`20625`).
Changes in the C API
--------------------
...
...
Lib/test/test_grammar.py
Dosyayı görüntüle @
026019f8
...
...
@@ -314,6 +314,13 @@ class GrammarTests(unittest.TestCase):
self
.
assertEqual
(
f
.
__annotations__
,
{
'b'
:
1
,
'c'
:
2
,
'e'
:
3
,
'g'
:
6
,
'h'
:
7
,
'j'
:
9
,
'k'
:
11
,
'return'
:
12
})
# Check for issue #20625 -- annotations mangling
class
Spam
:
def
f
(
self
,
*
,
__kw
:
1
):
pass
class
Ham
(
Spam
):
pass
self
.
assertEquals
(
Spam
.
f
.
__annotations__
,
{
'_Spam__kw'
:
1
})
self
.
assertEquals
(
Ham
.
f
.
__annotations__
,
{
'_Spam__kw'
:
1
})
# Check for SF Bug #1697248 - mixing decorators and a return annotation
def
null
(
x
):
return
x
@null
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
026019f8
...
...
@@ -2390,6 +2390,22 @@ class TestSignatureObject(unittest.TestCase):
self
.
assertEqual
(
sig
.
return_annotation
,
42
)
self
.
assertEqual
(
sig
,
inspect
.
signature
(
test
))
def
test_signature_on_mangled_parameters
(
self
):
class
Spam
:
def
foo
(
self
,
__p1
:
1
=
2
,
*
,
__p2
:
2
=
3
):
pass
class
Ham
(
Spam
):
pass
self
.
assertEqual
(
self
.
signature
(
Spam
.
foo
),
(((
'self'
,
...
,
...
,
"positional_or_keyword"
),
(
'_Spam__p1'
,
2
,
1
,
"positional_or_keyword"
),
(
'_Spam__p2'
,
3
,
2
,
"keyword_only"
)),
...
))
self
.
assertEqual
(
self
.
signature
(
Spam
.
foo
),
self
.
signature
(
Ham
.
foo
))
class
TestParameterObject
(
unittest
.
TestCase
):
def
test_signature_parameter_kinds
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
026019f8
...
...
@@ -10,6 +10,9 @@ Release date: 2014-02-23
Core and Builtins
-----------------
- Issue #20625: Parameter names in __annotations__ were not mangled properly.
Discovered by Jonas Wielicki, patch by Yury Selivanov.
- Issue #20261: In pickle, lookup __getnewargs__ and __getnewargs_ex__ on the
type of the object.
...
...
Python/compile.c
Dosyayı görüntüle @
026019f8
...
...
@@ -1533,8 +1533,14 @@ compiler_visit_argannotation(struct compiler *c, identifier id,
{
if
(
annotation
)
{
VISIT
(
c
,
expr
,
annotation
);
if
(
PyList_Append
(
names
,
id
))
PyObject
*
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
id
);
if
(
!
mangled
)
return
-
1
;
if
(
PyList_Append
(
names
,
mangled
)
<
0
)
{
Py_DECREF
(
mangled
);
return
-
1
;
}
Py_DECREF
(
mangled
);
}
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