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
deef6748
Kaydet (Commit)
deef6748
authored
Mar 14, 2008
tarafından
Thomas Wouters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix crasher in unpacking assignments with star, where the size constraints
weren't checked.
üst
4a983c55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
test_unpack_ex.py
Lib/test/test_unpack_ex.py
+17
-0
compile.c
Python/compile.c
+10
-0
No files found.
Lib/test/test_unpack_ex.py
Dosyayı görüntüle @
deef6748
...
...
@@ -143,6 +143,23 @@ Now some general starred expressions (all fail).
...
SyntaxError: can use starred expression only as assignment target
Some size constraints (all fail.)
>>> s = ", ".join("a
%
d"
%
i for i in range(1<<8)) + ", *rest = range(1<<8 + 1)"
>>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: too many expressions in star-unpacking assignment
>>> s = ", ".join("a
%
d"
%
i for i in range(1<<8 + 1)) + ", *rest = range(1<<8 + 2)"
>>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: too many expressions in star-unpacking assignment
(there is an additional limit, on the number of expressions after the
'*rest', but it's 1<<24 and testing it takes too much memory.)
"""
__test__
=
{
'doctests'
:
doctests
}
...
...
Python/compile.c
Dosyayı görüntüle @
deef6748
...
...
@@ -2614,6 +2614,11 @@ compiler_list(struct compiler *c, expr_ty e)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
expr_ty
elt
=
asdl_seq_GET
(
e
->
v
.
List
.
elts
,
i
);
if
(
elt
->
kind
==
Starred_kind
&&
!
seen_star
)
{
if
((
i
>=
(
1
<<
8
))
||
(
n
-
i
-
1
>=
(
INT_MAX
>>
8
)))
return
compiler_error
(
c
,
"too many expressions in "
"star-unpacking assignment"
);
ADDOP_I
(
c
,
UNPACK_EX
,
(
i
+
((
n
-
i
-
1
)
<<
8
)));
seen_star
=
1
;
asdl_seq_SET
(
e
->
v
.
List
.
elts
,
i
,
elt
->
v
.
Starred
.
value
);
...
...
@@ -2642,6 +2647,11 @@ compiler_tuple(struct compiler *c, expr_ty e)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
expr_ty
elt
=
asdl_seq_GET
(
e
->
v
.
Tuple
.
elts
,
i
);
if
(
elt
->
kind
==
Starred_kind
&&
!
seen_star
)
{
if
((
i
>=
(
1
<<
8
))
||
(
n
-
i
-
1
>=
(
INT_MAX
>>
8
)))
return
compiler_error
(
c
,
"too many expressions in "
"star-unpacking assignment"
);
ADDOP_I
(
c
,
UNPACK_EX
,
(
i
+
((
n
-
i
-
1
)
<<
8
)));
seen_star
=
1
;
asdl_seq_SET
(
e
->
v
.
Tuple
.
elts
,
i
,
elt
->
v
.
Starred
.
value
);
...
...
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