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
fe8440ae
Kaydet (Commit)
fe8440ae
authored
May 06, 2012
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #14965: Bring Tools/parser/unparse.py up to date with the Python 3.3. Grammar.
üst
6dbca367
1b2e9444
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
19 deletions
+60
-19
NEWS
Misc/NEWS
+6
-0
test_unparse.py
Tools/parser/test_unparse.py
+31
-0
unparse.py
Tools/parser/unparse.py
+23
-19
No files found.
Misc/NEWS
Dosyayı görüntüle @
fe8440ae
...
...
@@ -28,6 +28,12 @@ Library
- Issue #14127 and #10148: shutil.copystat now preserves exact mtime and atime
on filesystems providing nanosecond resolution.
Tools/Demos
-----------
- Issue #14965: Bring Tools/parser/unparse.py support up to date with
the Python 3.3 Grammar.
What'
s
New
in
Python
3.3.0
Alpha
3
?
===================================
...
...
Tools/parser/test_unparse.py
Dosyayı görüntüle @
fe8440ae
...
...
@@ -93,6 +93,21 @@ finally:
suite5
"""
with_simple
=
"""
\
with f():
suite1
"""
with_as
=
"""
\
with f() as x:
suite1
"""
with_two_items
=
"""
\
with f() as x, g() as y:
suite1
"""
class
ASTTestCase
(
unittest
.
TestCase
):
def
assertASTEqual
(
self
,
ast1
,
ast2
):
self
.
assertEqual
(
ast
.
dump
(
ast1
),
ast
.
dump
(
ast2
))
...
...
@@ -209,6 +224,22 @@ class UnparseTestCase(ASTTestCase):
def
test_try_except_finally
(
self
):
self
.
check_roundtrip
(
try_except_finally
)
def
test_starred_assignment
(
self
):
self
.
check_roundtrip
(
"a, *b, c = seq"
)
self
.
check_roundtrip
(
"a, (*b, c) = seq"
)
self
.
check_roundtrip
(
"a, *b[0], c = seq"
)
self
.
check_roundtrip
(
"a, *(b, c) = seq"
)
def
test_with_simple
(
self
):
self
.
check_roundtrip
(
with_simple
)
def
test_with_as
(
self
):
self
.
check_roundtrip
(
with_as
)
def
test_with_two_items
(
self
):
self
.
check_roundtrip
(
with_two_items
)
class
DirectoryTestCase
(
ASTTestCase
):
"""Test roundtrip behaviour on all files in Lib and Lib/test."""
...
...
Tools/parser/unparse.py
Dosyayı görüntüle @
fe8440ae
...
...
@@ -147,6 +147,14 @@ class Unparser:
self
.
dispatch
(
t
.
value
)
self
.
write
(
")"
)
def
_YieldFrom
(
self
,
t
):
self
.
write
(
"("
)
self
.
write
(
"yield from"
)
if
t
.
value
:
self
.
write
(
" "
)
self
.
dispatch
(
t
.
value
)
self
.
write
(
")"
)
def
_Raise
(
self
,
t
):
self
.
fill
(
"raise"
)
if
not
t
.
exc
:
...
...
@@ -158,12 +166,11 @@ class Unparser:
self
.
write
(
" from "
)
self
.
dispatch
(
t
.
cause
)
def
_Try
Except
(
self
,
t
):
def
_Try
(
self
,
t
):
self
.
fill
(
"try"
)
self
.
enter
()
self
.
dispatch
(
t
.
body
)
self
.
leave
()
for
ex
in
t
.
handlers
:
self
.
dispatch
(
ex
)
if
t
.
orelse
:
...
...
@@ -171,22 +178,12 @@ class Unparser:
self
.
enter
()
self
.
dispatch
(
t
.
orelse
)
self
.
leave
()
def
_TryFinally
(
self
,
t
):
if
len
(
t
.
body
)
==
1
and
isinstance
(
t
.
body
[
0
],
ast
.
TryExcept
):
# try-except-finally
self
.
dispatch
(
t
.
body
)
else
:
self
.
fill
(
"try"
)
if
t
.
finalbody
:
self
.
fill
(
"finally"
)
self
.
enter
()
self
.
dispatch
(
t
.
body
)
self
.
dispatch
(
t
.
final
body
)
self
.
leave
()
self
.
fill
(
"finally"
)
self
.
enter
()
self
.
dispatch
(
t
.
finalbody
)
self
.
leave
()
def
_ExceptHandler
(
self
,
t
):
self
.
fill
(
"except"
)
if
t
.
type
:
...
...
@@ -296,10 +293,7 @@ class Unparser:
def
_With
(
self
,
t
):
self
.
fill
(
"with "
)
self
.
dispatch
(
t
.
context_expr
)
if
t
.
optional_vars
:
self
.
write
(
" as "
)
self
.
dispatch
(
t
.
optional_vars
)
interleave
(
lambda
:
self
.
write
(
", "
),
self
.
dispatch
,
t
.
items
)
self
.
enter
()
self
.
dispatch
(
t
.
body
)
self
.
leave
()
...
...
@@ -472,6 +466,10 @@ class Unparser:
self
.
dispatch
(
t
.
slice
)
self
.
write
(
"]"
)
def
_Starred
(
self
,
t
):
self
.
write
(
"*"
)
self
.
dispatch
(
t
.
value
)
# slice
def
_Ellipsis
(
self
,
t
):
self
.
write
(
"..."
)
...
...
@@ -560,6 +558,12 @@ class Unparser:
if
t
.
asname
:
self
.
write
(
" as "
+
t
.
asname
)
def
_withitem
(
self
,
t
):
self
.
dispatch
(
t
.
context_expr
)
if
t
.
optional_vars
:
self
.
write
(
" as "
)
self
.
dispatch
(
t
.
optional_vars
)
def
roundtrip
(
filename
,
output
=
sys
.
stdout
):
with
open
(
filename
,
"rb"
)
as
pyfile
:
encoding
=
tokenize
.
detect_encoding
(
pyfile
.
readline
)[
0
]
...
...
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