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
015d8746
Kaydet (Commit)
015d8746
authored
Eyl 11, 2016
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28076: Variable annotations should be mangled for private names.
By Ivan Levkivskyi.
üst
a6d75fdc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
simple_stmts.rst
Doc/reference/simple_stmts.rst
+4
-3
test_grammar.py
Lib/test/test_grammar.py
+2
-2
compile.c
Python/compile.c
+7
-1
No files found.
Doc/reference/simple_stmts.rst
Dosyayı görüntüle @
015d8746
...
...
@@ -334,9 +334,10 @@ only single right hand side value is allowed.
For
simple
names
as
assignment
targets
,
if
in
class
or
module
scope
,
the
annotations
are
evaluated
and
stored
in
a
special
class
or
module
attribute
:
attr
:`
__annotations__
`
that
is
a
dictionary
mapping
from
variable
names
to
evaluated
annotations
.
This
attribute
is
writable
and
is
automatically
created
at
the
start
of
class
or
module
body
execution
,
if
annotations
are
found
statically
.
that
is
a
dictionary
mapping
from
variable
names
(
mangled
if
private
)
to
evaluated
annotations
.
This
attribute
is
writable
and
is
automatically
created
at
the
start
of
class
or
module
body
execution
,
if
annotations
are
found
statically
.
For
expressions
as
assignment
targets
,
the
annotations
are
evaluated
if
in
class
or
module
scope
,
but
not
stored
.
...
...
Lib/test/test_grammar.py
Dosyayı görüntüle @
015d8746
...
...
@@ -328,12 +328,12 @@ class GrammarTests(unittest.TestCase):
# class semantics
class
C
:
x
:
int
__foo
:
int
s
:
str
=
"attr"
z
=
2
def
__init__
(
self
,
x
):
self
.
x
:
int
=
x
self
.
assertEqual
(
C
.
__annotations__
,
{
'
x
'
:
int
,
's'
:
str
})
self
.
assertEqual
(
C
.
__annotations__
,
{
'
_C__foo
'
:
int
,
's'
:
str
})
with
self
.
assertRaises
(
NameError
):
class
CBad
:
no_such_name_defined
.
attr
:
int
=
0
...
...
Python/compile.c
Dosyayı görüntüle @
015d8746
...
...
@@ -4562,6 +4562,7 @@ static int
compiler_annassign
(
struct
compiler
*
c
,
stmt_ty
s
)
{
expr_ty
targ
=
s
->
v
.
AnnAssign
.
target
;
PyObject
*
mangled
;
assert
(
s
->
kind
==
AnnAssign_kind
);
...
...
@@ -4576,8 +4577,13 @@ compiler_annassign(struct compiler *c, stmt_ty s)
if
(
s
->
v
.
AnnAssign
.
simple
&&
(
c
->
u
->
u_scope_type
==
COMPILER_SCOPE_MODULE
||
c
->
u
->
u_scope_type
==
COMPILER_SCOPE_CLASS
))
{
mangled
=
_Py_Mangle
(
c
->
u
->
u_private
,
targ
->
v
.
Name
.
id
);
if
(
!
mangled
)
{
return
0
;
}
VISIT
(
c
,
expr
,
s
->
v
.
AnnAssign
.
annotation
);
ADDOP_O
(
c
,
STORE_ANNOTATION
,
targ
->
v
.
Name
.
id
,
names
)
/* ADDOP_N decrefs its argument */
ADDOP_N
(
c
,
STORE_ANNOTATION
,
mangled
,
names
);
}
break
;
case
Attribute_kind
:
...
...
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