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
dcaf329e
Kaydet (Commit)
dcaf329e
authored
Mar 03, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
instead of hacking __locals__ in during bytecode generation, put it in the symtable
üst
231b7f1c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
22 deletions
+6
-22
compile.c
Python/compile.c
+1
-20
symtable.c
Python/symtable.c
+5
-2
No files found.
Python/compile.c
Dosyayı görüntüle @
dcaf329e
...
...
@@ -1524,23 +1524,14 @@ compiler_function(struct compiler *c, stmt_ty s)
static
int
compiler_class
(
struct
compiler
*
c
,
stmt_ty
s
)
{
static
PyObject
*
locals
=
NULL
;
PyCodeObject
*
co
;
PyObject
*
str
;
PySTEntryObject
*
ste
;
int
err
,
i
;
int
i
;
asdl_seq
*
decos
=
s
->
v
.
ClassDef
.
decorator_list
;
if
(
!
compiler_decorators
(
c
,
decos
))
return
0
;
/* initialize statics */
if
(
locals
==
NULL
)
{
locals
=
PyUnicode_InternFromString
(
"__locals__"
);
if
(
locals
==
NULL
)
return
0
;
}
/* ultimately generate code for:
<name> = __build_class__(<func>, <name>, *<bases>, **<keywords>)
where:
...
...
@@ -1553,16 +1544,6 @@ compiler_class(struct compiler *c, stmt_ty s)
This borrows from compiler_call.
*/
/* 0. Create a fake argument named __locals__ */
ste
=
PySymtable_Lookup
(
c
->
c_st
,
s
);
if
(
ste
==
NULL
)
return
0
;
assert
(
PyList_Check
(
ste
->
ste_varnames
));
err
=
PyList_Append
(
ste
->
ste_varnames
,
locals
);
Py_DECREF
(
ste
);
if
(
err
<
0
)
return
0
;
/* 1. compile the class body into a code object */
if
(
!
compiler_enter_scope
(
c
,
s
->
v
.
ClassDef
.
name
,
(
void
*
)
s
,
s
->
lineno
))
return
0
;
...
...
Python/symtable.c
Dosyayı görüntüle @
dcaf329e
...
...
@@ -186,7 +186,8 @@ static int symtable_visit_annotations(struct symtable *st, stmt_ty s);
static
identifier
top
=
NULL
,
lambda
=
NULL
,
genexpr
=
NULL
,
listcomp
=
NULL
,
setcomp
=
NULL
,
dictcomp
=
NULL
,
__class__
=
NULL
;
listcomp
=
NULL
,
setcomp
=
NULL
,
dictcomp
=
NULL
,
__class__
=
NULL
,
__locals__
=
NULL
;
#define GET_IDENTIFIER(VAR) \
((VAR) ? (VAR) : ((VAR) = PyUnicode_InternFromString(# VAR)))
...
...
@@ -1050,7 +1051,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
(
void
*
)
s
,
s
->
lineno
))
return
0
;
if
(
!
GET_IDENTIFIER
(
__class__
)
||
!
symtable_add_def
(
st
,
__class__
,
DEF_LOCAL
))
{
!
symtable_add_def
(
st
,
__class__
,
DEF_LOCAL
)
||
!
GET_IDENTIFIER
(
__locals__
)
||
!
symtable_add_def
(
st
,
__locals__
,
DEF_PARAM
))
{
symtable_exit_block
(
st
,
s
);
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