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
3cc8f4b9
Kaydet (Commit)
3cc8f4b9
authored
Ara 29, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make recording and reporting errors and nonlocal and global directives more robust (closes #25973)
üst
01f7ac3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
8 deletions
+27
-8
test_syntax.py
Lib/test/test_syntax.py
+8
-0
NEWS
Misc/NEWS
+3
-0
symtable.c
Python/symtable.c
+16
-8
No files found.
Lib/test/test_syntax.py
Dosyayı görüntüle @
3cc8f4b9
...
...
@@ -416,6 +416,14 @@ TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
From https://bugs.python.org/issue25973
>>> class A:
... def f(self):
... nonlocal __x
Traceback (most recent call last):
...
SyntaxError: no binding for nonlocal '_A__x' found
This tests assignment-context; there was a bug in Python 2.5 where compiling
a complex 'if' (one with 'elif') would fail to notice an invalid suite,
...
...
Misc/NEWS
Dosyayı görüntüle @
3cc8f4b9
...
...
@@ -10,6 +10,9 @@ Release date: tba
Core and Builtins
-----------------
- Issue #25973: Fix segfault when an invalid nonlocal statement binds a name
starting with two underscores.
- Issue #22995: Instances of extension types with a state that aren'
t
subclasses
of
list
or
dict
and
haven
't implemented any pickle-related
methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
...
...
Python/symtable.c
Dosyayı görüntüle @
3cc8f4b9
...
...
@@ -368,15 +368,20 @@ error_at_directive(PySTEntryObject *ste, PyObject *name)
Py_ssize_t
i
;
PyObject
*
data
;
assert
(
ste
->
ste_directives
);
for
(
i
=
0
;
;
i
++
)
{
for
(
i
=
0
;
i
<
PyList_GET_SIZE
(
ste
->
ste_directives
)
;
i
++
)
{
data
=
PyList_GET_ITEM
(
ste
->
ste_directives
,
i
);
assert
(
PyTuple_CheckExact
(
data
));
if
(
PyTuple_GET_ITEM
(
data
,
0
)
==
name
)
break
;
assert
(
PyUnicode_CheckExact
(
PyTuple_GET_ITEM
(
data
,
0
)));
if
(
PyUnicode_Compare
(
PyTuple_GET_ITEM
(
data
,
0
),
name
)
==
0
)
{
PyErr_SyntaxLocationObject
(
ste
->
ste_table
->
st_filename
,
PyLong_AsLong
(
PyTuple_GET_ITEM
(
data
,
1
)),
PyLong_AsLong
(
PyTuple_GET_ITEM
(
data
,
2
)));
return
0
;
}
}
PyErr_SyntaxLocationObject
(
ste
->
ste_table
->
st_filename
,
PyLong_AsLong
(
PyTuple_GET_ITEM
(
data
,
1
)),
PyLong_AsLong
(
PyTuple_GET_ITEM
(
data
,
2
)));
PyErr_SetString
(
PyExc_RuntimeError
,
"BUG: internal directive bookkeeping broken"
);
return
0
;
}
...
...
@@ -1115,14 +1120,17 @@ symtable_new_tmpname(struct symtable *st)
static
int
symtable_record_directive
(
struct
symtable
*
st
,
identifier
name
,
stmt_ty
s
)
{
PyObject
*
data
;
PyObject
*
data
,
*
mangled
;
int
res
;
if
(
!
st
->
st_cur
->
ste_directives
)
{
st
->
st_cur
->
ste_directives
=
PyList_New
(
0
);
if
(
!
st
->
st_cur
->
ste_directives
)
return
0
;
}
data
=
Py_BuildValue
(
"(Oii)"
,
name
,
s
->
lineno
,
s
->
col_offset
);
mangled
=
_Py_Mangle
(
st
->
st_private
,
name
);
if
(
!
mangled
)
return
0
;
data
=
Py_BuildValue
(
"(Nii)"
,
mangled
,
s
->
lineno
,
s
->
col_offset
);
if
(
!
data
)
return
0
;
res
=
PyList_Append
(
st
->
st_cur
->
ste_directives
,
data
);
...
...
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