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
4879c907
Kaydet (Commit)
4879c907
authored
Tem 20, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
the Slice in x[::] has to have step as None to help the interpreter
üst
a2514f4c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
test_ast.py
Lib/test/test_ast.py
+2
-1
NEWS
Misc/NEWS
+0
-3
ast.c
Python/ast.c
+15
-1
No files found.
Lib/test/test_ast.py
Dosyayı görüntüle @
4879c907
...
...
@@ -150,7 +150,8 @@ class AST_Tests(unittest.TestCase):
slc
=
ast
.
parse
(
"x[::]"
)
.
body
[
0
]
.
value
.
slice
self
.
assertIsNone
(
slc
.
upper
)
self
.
assertIsNone
(
slc
.
lower
)
self
.
assertIsNone
(
slc
.
step
)
self
.
assertTrue
(
isinstance
(
slc
.
step
,
ast
.
Name
))
self
.
assertEqual
(
slc
.
step
.
id
,
"None"
)
def
test_from_import
(
self
):
im
=
ast
.
parse
(
"from . import y"
)
.
body
[
0
]
...
...
Misc/NEWS
Dosyayı görüntüle @
4879c907
...
...
@@ -44,9 +44,6 @@ Core and Builtins
- Assignment to None using import statements now raises a SyntaxError.
- In the slice AST type, the step field will always be None if a step expression
is not specified.
- Issue #4547: When debugging a very large function, it was not always
possible to update the lineno attribute of the current frame.
...
...
Python/ast.c
Dosyayı görüntüle @
4879c907
...
...
@@ -1471,7 +1471,21 @@ ast_for_slice(struct compiling *c, const node *n)
ch
=
CHILD
(
n
,
NCH
(
n
)
-
1
);
if
(
TYPE
(
ch
)
==
sliceop
)
{
if
(
NCH
(
ch
)
!=
1
)
{
if
(
NCH
(
ch
)
==
1
)
{
/*
This is an extended slice (ie "x[::]") with no expression in the
step field. We set this literally to "None" in order to
disambiguate it from x[:]. (The interpreter might have to call
__getslice__ for x[:], but it must call __getitem__ for x[::].)
*/
identifier
none
=
new_identifier
(
"None"
,
c
->
c_arena
);
if
(
!
none
)
return
NULL
;
ch
=
CHILD
(
ch
,
0
);
step
=
Name
(
none
,
Load
,
LINENO
(
ch
),
ch
->
n_col_offset
,
c
->
c_arena
);
if
(
!
step
)
return
NULL
;
}
else
{
ch
=
CHILD
(
ch
,
1
);
if
(
TYPE
(
ch
)
==
test
)
{
step
=
ast_for_expr
(
c
,
ch
);
...
...
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