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
c0ba8288
Kaydet (Commit)
c0ba8288
authored
Agu 15, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
better col_offsets for "for" statements with tuple unpacking #6704
Patch from Frank Wierzbicki.
üst
8cabfa35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
test_ast.py
Lib/test/test_ast.py
+8
-1
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
ast.c
Python/ast.c
+12
-11
No files found.
Lib/test/test_ast.py
Dosyayı görüntüle @
c0ba8288
...
@@ -64,6 +64,10 @@ exec_tests = [
...
@@ -64,6 +64,10 @@ exec_tests = [
"break"
,
"break"
,
# Continue
# Continue
"continue"
,
"continue"
,
# for statements with naked tuples (see http://bugs.python.org/issue6704)
"for a,b in c: pass"
,
"[(a,b) for a,b in c]"
,
"((a,b) for a,b in c)"
,
]
]
# These are compiled through "single"
# These are compiled through "single"
...
@@ -301,7 +305,7 @@ def main():
...
@@ -301,7 +305,7 @@ def main():
print
kind
+
"_results = ["
print
kind
+
"_results = ["
for
s
in
statements
:
for
s
in
statements
:
print
repr
(
to_tuple
(
compile
(
s
,
"?"
,
kind
,
0x400
)))
+
","
print
repr
(
to_tuple
(
compile
(
s
,
"?"
,
kind
,
0x400
)))
+
","
print
"]"
print
"]"
print
"main()"
print
"main()"
raise
SystemExit
raise
SystemExit
test_main
()
test_main
()
...
@@ -330,6 +334,9 @@ exec_results = [
...
@@ -330,6 +334,9 @@ exec_results = [
(
'Module'
,
[(
'Pass'
,
(
1
,
0
))]),
(
'Module'
,
[(
'Pass'
,
(
1
,
0
))]),
(
'Module'
,
[(
'Break'
,
(
1
,
0
))]),
(
'Module'
,
[(
'Break'
,
(
1
,
0
))]),
(
'Module'
,
[(
'Continue'
,
(
1
,
0
))]),
(
'Module'
,
[(
'Continue'
,
(
1
,
0
))]),
(
'Module'
,
[(
'For'
,
(
1
,
0
),
(
'Tuple'
,
(
1
,
4
),
[(
'Name'
,
(
1
,
4
),
'a'
,
(
'Store'
,)),
(
'Name'
,
(
1
,
6
),
'b'
,
(
'Store'
,))],
(
'Store'
,)),
(
'Name'
,
(
1
,
11
),
'c'
,
(
'Load'
,)),
[(
'Pass'
,
(
1
,
14
))],
[])]),
(
'Module'
,
[(
'Expr'
,
(
1
,
0
),
(
'ListComp'
,
(
1
,
1
),
(
'Tuple'
,
(
1
,
2
),
[(
'Name'
,
(
1
,
2
),
'a'
,
(
'Load'
,)),
(
'Name'
,
(
1
,
4
),
'b'
,
(
'Load'
,))],
(
'Load'
,)),
[(
'comprehension'
,
(
'Tuple'
,
(
1
,
11
),
[(
'Name'
,
(
1
,
11
),
'a'
,
(
'Store'
,)),
(
'Name'
,
(
1
,
13
),
'b'
,
(
'Store'
,))],
(
'Store'
,)),
(
'Name'
,
(
1
,
18
),
'c'
,
(
'Load'
,)),
[])]))]),
(
'Module'
,
[(
'Expr'
,
(
1
,
0
),
(
'GeneratorExp'
,
(
1
,
1
),
(
'Tuple'
,
(
1
,
2
),
[(
'Name'
,
(
1
,
2
),
'a'
,
(
'Load'
,)),
(
'Name'
,
(
1
,
4
),
'b'
,
(
'Load'
,))],
(
'Load'
,)),
[(
'comprehension'
,
(
'Tuple'
,
(
1
,
11
),
[(
'Name'
,
(
1
,
11
),
'a'
,
(
'Store'
,)),
(
'Name'
,
(
1
,
13
),
'b'
,
(
'Store'
,))],
(
'Store'
,)),
(
'Name'
,
(
1
,
18
),
'c'
,
(
'Load'
,)),
[])]))]),
]
]
single_results
=
[
single_results
=
[
(
'Interactive'
,
[(
'Expr'
,
(
1
,
0
),
(
'BinOp'
,
(
1
,
0
),
(
'Num'
,
(
1
,
0
),
1
),
(
'Add'
,),
(
'Num'
,
(
1
,
2
),
2
)))]),
(
'Interactive'
,
[(
'Expr'
,
(
1
,
0
),
(
'BinOp'
,
(
1
,
0
),
(
'Num'
,
(
1
,
0
),
1
),
(
'Add'
,),
(
'Num'
,
(
1
,
2
),
2
)))]),
...
...
Misc/ACKS
Dosyayı görüntüle @
c0ba8288
...
@@ -794,6 +794,7 @@ Collin Winter
...
@@ -794,6 +794,7 @@ Collin Winter
Dik Winter
Dik Winter
Blake Winton
Blake Winton
Jean-Claude Wippler
Jean-Claude Wippler
Frank Wierzbicki
Lars Wirzenius
Lars Wirzenius
Chris Withers
Chris Withers
Stefan Witzel
Stefan Witzel
...
...
Misc/NEWS
Dosyayı görüntüle @
c0ba8288
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #6704: Improve the col_offset in AST for "for" statements with
a target of tuple unpacking.
- Issue #6707: dir() on an uninitialized module caused a crash.
- Issue #6707: dir() on an uninitialized module caused a crash.
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
...
...
Python/ast.c
Dosyayı görüntüle @
c0ba8288
...
@@ -1047,7 +1047,7 @@ ast_for_listcomp(struct compiling *c, const node *n)
...
@@ -1047,7 +1047,7 @@ ast_for_listcomp(struct compiling *c, const node *n)
list_if: 'if' test [list_iter]
list_if: 'if' test [list_iter]
testlist_safe: test [(',' test)+ [',']]
testlist_safe: test [(',' test)+ [',']]
*/
*/
expr_ty
elt
;
expr_ty
elt
,
first
;
asdl_seq
*
listcomps
;
asdl_seq
*
listcomps
;
int
i
,
n_fors
;
int
i
,
n_fors
;
node
*
ch
;
node
*
ch
;
...
@@ -1087,11 +1087,11 @@ ast_for_listcomp(struct compiling *c, const node *n)
...
@@ -1087,11 +1087,11 @@ ast_for_listcomp(struct compiling *c, const node *n)
/* Check the # of children rather than the length of t, since
/* Check the # of children rather than the length of t, since
[x for x, in ... ] has 1 element in t, but still requires a Tuple.
[x for x, in ... ] has 1 element in t, but still requires a Tuple.
*/
*/
first
=
(
expr_ty
)
asdl_seq_GET
(
t
,
0
);
if
(
NCH
(
for_ch
)
==
1
)
if
(
NCH
(
for_ch
)
==
1
)
lc
=
comprehension
((
expr_ty
)
asdl_seq_GET
(
t
,
0
),
expression
,
NULL
,
lc
=
comprehension
(
first
,
expression
,
NULL
,
c
->
c_arena
);
c
->
c_arena
);
else
else
lc
=
comprehension
(
Tuple
(
t
,
Store
,
LINENO
(
ch
),
ch
->
n_
col_offset
,
lc
=
comprehension
(
Tuple
(
t
,
Store
,
first
->
lineno
,
first
->
col_offset
,
c
->
c_arena
),
c
->
c_arena
),
expression
,
NULL
,
c
->
c_arena
);
expression
,
NULL
,
c
->
c_arena
);
if
(
!
lc
)
if
(
!
lc
)
...
@@ -1226,7 +1226,7 @@ ast_for_genexp(struct compiling *c, const node *n)
...
@@ -1226,7 +1226,7 @@ ast_for_genexp(struct compiling *c, const node *n)
for
(
i
=
0
;
i
<
n_fors
;
i
++
)
{
for
(
i
=
0
;
i
<
n_fors
;
i
++
)
{
comprehension_ty
ge
;
comprehension_ty
ge
;
asdl_seq
*
t
;
asdl_seq
*
t
;
expr_ty
expression
;
expr_ty
expression
,
first
;
node
*
for_ch
;
node
*
for_ch
;
REQ
(
ch
,
gen_for
);
REQ
(
ch
,
gen_for
);
...
@@ -1241,11 +1241,11 @@ ast_for_genexp(struct compiling *c, const node *n)
...
@@ -1241,11 +1241,11 @@ ast_for_genexp(struct compiling *c, const node *n)
/* Check the # of children rather than the length of t, since
/* Check the # of children rather than the length of t, since
(x for x, in ...) has 1 element in t, but still requires a Tuple. */
(x for x, in ...) has 1 element in t, but still requires a Tuple. */
first
=
(
expr_ty
)
asdl_seq_GET
(
t
,
0
);
if
(
NCH
(
for_ch
)
==
1
)
if
(
NCH
(
for_ch
)
==
1
)
ge
=
comprehension
((
expr_ty
)
asdl_seq_GET
(
t
,
0
),
expression
,
ge
=
comprehension
(
first
,
expression
,
NULL
,
c
->
c_arena
);
NULL
,
c
->
c_arena
);
else
else
ge
=
comprehension
(
Tuple
(
t
,
Store
,
LINENO
(
ch
),
ch
->
n_
col_offset
,
ge
=
comprehension
(
Tuple
(
t
,
Store
,
first
->
lineno
,
first
->
col_offset
,
c
->
c_arena
),
c
->
c_arena
),
expression
,
NULL
,
c
->
c_arena
);
expression
,
NULL
,
c
->
c_arena
);
...
@@ -2844,7 +2844,7 @@ ast_for_for_stmt(struct compiling *c, const node *n)
...
@@ -2844,7 +2844,7 @@ ast_for_for_stmt(struct compiling *c, const node *n)
{
{
asdl_seq
*
_target
,
*
seq
=
NULL
,
*
suite_seq
;
asdl_seq
*
_target
,
*
seq
=
NULL
,
*
suite_seq
;
expr_ty
expression
;
expr_ty
expression
;
expr_ty
target
;
expr_ty
target
,
first
;
const
node
*
node_target
;
const
node
*
node_target
;
/* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */
/* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */
REQ
(
n
,
for_stmt
);
REQ
(
n
,
for_stmt
);
...
@@ -2861,10 +2861,11 @@ ast_for_for_stmt(struct compiling *c, const node *n)
...
@@ -2861,10 +2861,11 @@ ast_for_for_stmt(struct compiling *c, const node *n)
return
NULL
;
return
NULL
;
/* Check the # of children rather than the length of _target, since
/* Check the # of children rather than the length of _target, since
for x, in ... has 1 element in _target, but still requires a Tuple. */
for x, in ... has 1 element in _target, but still requires a Tuple. */
first
=
(
expr_ty
)
asdl_seq_GET
(
_target
,
0
);
if
(
NCH
(
node_target
)
==
1
)
if
(
NCH
(
node_target
)
==
1
)
target
=
(
expr_ty
)
asdl_seq_GET
(
_target
,
0
)
;
target
=
first
;
else
else
target
=
Tuple
(
_target
,
Store
,
LINENO
(
n
),
n
->
n_
col_offset
,
c
->
c_arena
);
target
=
Tuple
(
_target
,
Store
,
first
->
lineno
,
first
->
col_offset
,
c
->
c_arena
);
expression
=
ast_for_testlist
(
c
,
CHILD
(
n
,
3
));
expression
=
ast_for_testlist
(
c
,
CHILD
(
n
,
3
));
if
(
!
expression
)
if
(
!
expression
)
...
...
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