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
d07a1cb5
Kaydet (Commit)
d07a1cb5
authored
Mar 06, 2016
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #26489: Add dictionary unpacking support to Tools/parser/unparse.py
Patch by Guo Ci Teo.
üst
48238c7e
d66dd5ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
test_unparse.py
Lib/test/test_tools/test_unparse.py
+5
-0
NEWS
Misc/NEWS
+3
-0
unparse.py
Tools/parser/unparse.py
+12
-3
No files found.
Lib/test/test_tools/test_unparse.py
Dosyayı görüntüle @
d07a1cb5
...
@@ -259,6 +259,11 @@ class UnparseTestCase(ASTTestCase):
...
@@ -259,6 +259,11 @@ class UnparseTestCase(ASTTestCase):
def
test_with_two_items
(
self
):
def
test_with_two_items
(
self
):
self
.
check_roundtrip
(
with_two_items
)
self
.
check_roundtrip
(
with_two_items
)
def
test_dict_unpacking_in_dict
(
self
):
# See issue 26489
self
.
check_roundtrip
(
r"""{**{'y': 2}, 'x': 1}"""
)
self
.
check_roundtrip
(
r"""{**{'y': 2}, **{'x': 1}}"""
)
class
DirectoryTestCase
(
ASTTestCase
):
class
DirectoryTestCase
(
ASTTestCase
):
"""Test roundtrip behaviour on all files in Lib and Lib/test."""
"""Test roundtrip behaviour on all files in Lib and Lib/test."""
...
...
Misc/NEWS
Dosyayı görüntüle @
d07a1cb5
...
@@ -828,6 +828,9 @@ Windows
...
@@ -828,6 +828,9 @@ Windows
Tools/Demos
Tools/Demos
-----------
-----------
- Issue #26489: Add dictionary unpacking support to Tools/parser/unparse.py.
Patch by Guo Ci Teo.
- Issue #26316: Fix variable name typo in Argument Clinic.
- Issue #26316: Fix variable name typo in Argument Clinic.
- Issue #25440: Fix output of python-config --extension-suffix.
- Issue #25440: Fix output of python-config --extension-suffix.
...
...
Tools/parser/unparse.py
Dosyayı görüntüle @
d07a1cb5
...
@@ -456,12 +456,21 @@ class Unparser:
...
@@ -456,12 +456,21 @@ class Unparser:
def
_Dict
(
self
,
t
):
def
_Dict
(
self
,
t
):
self
.
write
(
"{"
)
self
.
write
(
"{"
)
def
write_pair
(
pair
):
def
write_key_value_pair
(
k
,
v
):
(
k
,
v
)
=
pair
self
.
dispatch
(
k
)
self
.
dispatch
(
k
)
self
.
write
(
": "
)
self
.
write
(
": "
)
self
.
dispatch
(
v
)
self
.
dispatch
(
v
)
interleave
(
lambda
:
self
.
write
(
", "
),
write_pair
,
zip
(
t
.
keys
,
t
.
values
))
def
write_item
(
item
):
k
,
v
=
item
if
k
is
None
:
# for dictionary unpacking operator in dicts {**{'y': 2}}
# see PEP 448 for details
self
.
write
(
"**"
)
self
.
dispatch
(
v
)
else
:
write_key_value_pair
(
k
,
v
)
interleave
(
lambda
:
self
.
write
(
", "
),
write_item
,
zip
(
t
.
keys
,
t
.
values
))
self
.
write
(
"}"
)
self
.
write
(
"}"
)
def
_Tuple
(
self
,
t
):
def
_Tuple
(
self
,
t
):
...
...
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