Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fa19a25c
Commit
fa19a25c
authored
May 19, 2019
by
Batuhan Taşkaya
Committed by
Pablo Galindo
May 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for PEP572 in ast_unparse.c (GH-13337)
parent
eab99650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
Lib/test/test_future.py
Lib/test/test_future.py
+2
-0
Misc/NEWS.d/next/Core and Builtins/2019-05-15-14-01-09.bpo-36826.GLrO3W.rst
...ore and Builtins/2019-05-15-14-01-09.bpo-36826.GLrO3W.rst
+1
-0
Python/ast_unparse.c
Python/ast_unparse.c
+13
-0
No files found.
Lib/test/test_future.py
View file @
fa19a25c
...
...
@@ -275,6 +275,8 @@ class AnnotationsFutureTestCase(unittest.TestCase):
eq
(
'f((x for x in a), 2)'
)
eq
(
'(((a)))'
,
'a'
)
eq
(
'(((a, b)))'
,
'(a, b)'
)
eq
(
"(x:=10)"
)
eq
(
"f'{(x:=10):=10}'"
)
if
__name__
==
"__main__"
:
...
...
Misc/NEWS.d/next/Core and Builtins/2019-05-15-14-01-09.bpo-36826.GLrO3W.rst
0 → 100644
View file @
fa19a25c
Add NamedExpression kind support to ast_unparse.c
Python/ast_unparse.c
View file @
fa19a25c
...
...
@@ -809,6 +809,17 @@ append_ast_await(_PyUnicodeWriter *writer, expr_ty e, int level)
return
0
;
}
static
int
append_named_expr
(
_PyUnicodeWriter
*
writer
,
expr_ty
e
,
int
level
)
{
APPEND_STR_IF
(
level
>
PR_TUPLE
,
"("
);
APPEND_EXPR
(
e
->
v
.
NamedExpr
.
target
,
PR_ATOM
);
APPEND_STR
(
":="
);
APPEND_EXPR
(
e
->
v
.
NamedExpr
.
value
,
PR_ATOM
);
APPEND_STR_IF
(
level
>
PR_TUPLE
,
")"
);
return
0
;
}
static
int
append_ast_expr
(
_PyUnicodeWriter
*
writer
,
expr_ty
e
,
int
level
)
{
...
...
@@ -867,6 +878,8 @@ append_ast_expr(_PyUnicodeWriter *writer, expr_ty e, int level)
return
append_ast_list
(
writer
,
e
);
case
Tuple_kind
:
return
append_ast_tuple
(
writer
,
e
,
level
);
case
NamedExpr_kind
:
return
append_named_expr
(
writer
,
e
,
level
);
default:
PyErr_SetString
(
PyExc_SystemError
,
"unknown expression kind"
);
...
...
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