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
619e7ba8
Kaydet (Commit)
619e7ba8
authored
Ock 09, 2011
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10869: do not visit root node twice in ast.increment_lineno().
üst
5b2d9ddf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
8 deletions
+17
-8
ast.rst
Doc/library/ast.rst
+3
-3
ast.py
Lib/ast.py
+3
-5
test_ast.py
Lib/test/test_ast.py
+7
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/ast.rst
Dosyayı görüntüle @
619e7ba8
...
@@ -173,9 +173,9 @@ and classes for traversing abstract syntax trees:
...
@@ -173,9 +173,9 @@ and classes for traversing abstract syntax trees:
.. function:: walk(node)
.. function:: walk(node)
Recursively yield all
child nodes of *node*, in no specified order. This is
Recursively yield all
descendant nodes in the tree starting at *node*
useful if you only want to modify nodes in place and don't care about the
(including *node* itself), in no specified order. This is useful if you only
context.
want to modify nodes in place and don't care about the
context.
.. class:: NodeVisitor()
.. class:: NodeVisitor()
...
...
Lib/ast.py
Dosyayı görüntüle @
619e7ba8
...
@@ -159,8 +159,6 @@ def increment_lineno(node, n=1):
...
@@ -159,8 +159,6 @@ def increment_lineno(node, n=1):
Increment the line number of each node in the tree starting at *node* by *n*.
Increment the line number of each node in the tree starting at *node* by *n*.
This is useful to "move code" to a different location in a file.
This is useful to "move code" to a different location in a file.
"""
"""
if
'lineno'
in
node
.
_attributes
:
node
.
lineno
=
getattr
(
node
,
'lineno'
,
0
)
+
n
for
child
in
walk
(
node
):
for
child
in
walk
(
node
):
if
'lineno'
in
child
.
_attributes
:
if
'lineno'
in
child
.
_attributes
:
child
.
lineno
=
getattr
(
child
,
'lineno'
,
0
)
+
n
child
.
lineno
=
getattr
(
child
,
'lineno'
,
0
)
+
n
...
@@ -211,9 +209,9 @@ def get_docstring(node, clean=True):
...
@@ -211,9 +209,9 @@ def get_docstring(node, clean=True):
def
walk
(
node
):
def
walk
(
node
):
"""
"""
Recursively yield all
child nodes of *node*, in no specified order. This is
Recursively yield all
descendant nodes in the tree starting at *node*
useful if you only want to modify nodes in place and don't care about the
(including *node* itself), in no specified order. This is useful if you
context.
only want to modify nodes in place and don't care about the
context.
"""
"""
from
collections
import
deque
from
collections
import
deque
todo
=
deque
([
node
])
todo
=
deque
([
node
])
...
...
Lib/test/test_ast.py
Dosyayı görüntüle @
619e7ba8
...
@@ -264,6 +264,13 @@ class ASTHelpers_Test(unittest.TestCase):
...
@@ -264,6 +264,13 @@ class ASTHelpers_Test(unittest.TestCase):
'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
'col_offset=0))'
'col_offset=0))'
)
)
# issue10869: do not increment lineno of root twice
self
.
assertEqual
(
ast
.
increment_lineno
(
src
.
body
,
n
=
3
),
src
.
body
)
self
.
assertEqual
(
ast
.
dump
(
src
,
include_attributes
=
True
),
'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), '
'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
'col_offset=0))'
)
def
test_iter_fields
(
self
):
def
test_iter_fields
(
self
):
node
=
ast
.
parse
(
'foo()'
,
mode
=
'eval'
)
node
=
ast
.
parse
(
'foo()'
,
mode
=
'eval'
)
...
...
Misc/ACKS
Dosyayı görüntüle @
619e7ba8
...
@@ -905,6 +905,7 @@ Cliff Wells
...
@@ -905,6 +905,7 @@ Cliff Wells
Rickard Westman
Rickard Westman
Jeff Wheeler
Jeff Wheeler
Christopher White
Christopher White
David White
Mats Wichmann
Mats Wichmann
Truida Wiedijk
Truida Wiedijk
Felix Wiemann
Felix Wiemann
...
...
Misc/NEWS
Dosyayı görüntüle @
619e7ba8
...
@@ -40,6 +40,9 @@ Core and Builtins
...
@@ -40,6 +40,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #10869: Fixed bug where ast.increment_lineno modified the root
node twice.
- Issue #5871: email.header.Header.encode now raises an error if any
- Issue #5871: email.header.Header.encode now raises an error if any
continuation line in the formatted value has no leading white space
continuation line in the formatted value has no leading white space
and looks like a header. Since Generator uses Header to format all
and looks like a header. Since Generator uses Header to format all
...
...
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