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
c176132d
Kaydet (Commit)
c176132d
authored
Şub 28, 2001
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Warn about global statement at the module level.
Do better accounting for global variables.
üst
56ba72a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
compile.c
Python/compile.c
+17
-2
No files found.
Python/compile.c
Dosyayı görüntüle @
c176132d
...
...
@@ -4178,7 +4178,7 @@ symtable_check_shadow(struct symtable *st, PyObject *name, int flags)
{
char
buf
[
500
];
PyObject
*
children
,
*
v
;
PySymtableEntryObject
*
child
;
PySymtableEntryObject
*
child
=
NULL
;
int
i
;
if
(
!
(
flags
&
DEF_BOUND
))
...
...
@@ -4202,7 +4202,9 @@ symtable_check_shadow(struct symtable *st, PyObject *name, int flags)
if
(
!
(
cflags
&
DEF_BOUND
))
break
;
}
assert
(
child
!=
NULL
);
sprintf
(
buf
,
"local name '%.100s' in '%.100s' shadows "
"use of '%.100s' as global in nested scope '%.100s'"
,
PyString_AS_STRING
(
name
),
...
...
@@ -4328,6 +4330,10 @@ symtable_load_symbols(struct compiling *c)
if
(
PyDict_SetItem
(
c
->
c_globals
,
name
,
implicit
)
<
0
)
goto
fail
;
v
=
PyInt_FromLong
(
flags
);
if
(
PyDict_SetItem
(
st
->
st_global
,
name
,
v
))
goto
fail
;
Py_DECREF
(
v
);
}
}
}
...
...
@@ -4360,6 +4366,7 @@ symtable_init()
st
->
st_nscopes
=
0
;
st
->
st_errors
=
0
;
st
->
st_tmpname
=
0
;
st
->
st_global_star
=
0
;
st
->
st_private
=
NULL
;
return
st
;
fail:
...
...
@@ -4922,6 +4929,12 @@ symtable_global(struct symtable *st, node *n)
{
int
i
;
if
(
st
->
st_nscopes
==
1
)
{
if
(
symtable_warn
(
st
,
"global statement has no meaning at module level"
)
<
0
)
return
;
}
for
(
i
=
1
;
i
<
NCH
(
n
);
i
+=
2
)
{
char
*
name
=
STR
(
CHILD
(
n
,
i
));
int
flags
;
...
...
@@ -4991,6 +5004,8 @@ symtable_import(struct symtable *st, node *n)
}
if
(
TYPE
(
CHILD
(
n
,
3
))
==
STAR
)
{
st
->
st_cur
->
ste_optimized
|=
OPT_IMPORT_STAR
;
if
(
st
->
st_nscopes
==
1
)
st
->
st_global_star
=
1
;
}
else
{
for
(
i
=
3
;
i
<
NCH
(
n
);
i
+=
2
)
{
node
*
c
=
CHILD
(
n
,
i
);
...
...
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