Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e989f760
Commit
e989f760
authored
Aug 21, 2019
by
demiurg337
Committed by
Stefan Behnel
Aug 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow await inside of f-strings (GH-3070)
parent
6b01c372
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
Cython/Compiler/Scanning.pxd
Cython/Compiler/Scanning.pxd
+1
-1
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+14
-7
tests/run/fstring.pyx
tests/run/fstring.pyx
+18
-0
No files found.
Cython/Compiler/Scanning.pxd
View file @
e989f760
...
@@ -38,7 +38,7 @@ cdef class PyrexScanner(Scanner):
...
@@ -38,7 +38,7 @@ cdef class PyrexScanner(Scanner):
cdef
public
list
indentation_stack
cdef
public
list
indentation_stack
cdef
public
indentation_char
cdef
public
indentation_char
cdef
public
int
bracket_nesting_level
cdef
public
int
bracket_nesting_level
cdef
bint
async_enabled
cdef
readonly
bint
async_enabled
cdef
public
sy
cdef
public
sy
cdef
public
systring
cdef
public
systring
...
...
Cython/Compiler/Scanning.py
View file @
e989f760
...
@@ -322,12 +322,25 @@ class PyrexScanner(Scanner):
...
@@ -322,12 +322,25 @@ class PyrexScanner(Scanner):
def
__init__
(
self
,
file
,
filename
,
parent_scanner
=
None
,
def
__init__
(
self
,
file
,
filename
,
parent_scanner
=
None
,
scope
=
None
,
context
=
None
,
source_encoding
=
None
,
parse_comments
=
True
,
initial_pos
=
None
):
scope
=
None
,
context
=
None
,
source_encoding
=
None
,
parse_comments
=
True
,
initial_pos
=
None
):
Scanner
.
__init__
(
self
,
get_lexicon
(),
file
,
filename
,
initial_pos
)
Scanner
.
__init__
(
self
,
get_lexicon
(),
file
,
filename
,
initial_pos
)
if
filename
.
is_python_file
():
self
.
in_python_file
=
True
self
.
keywords
=
set
(
py_reserved_words
)
else
:
self
.
in_python_file
=
False
self
.
keywords
=
set
(
pyx_reserved_words
)
self
.
async_enabled
=
0
if
parent_scanner
:
if
parent_scanner
:
self
.
context
=
parent_scanner
.
context
self
.
context
=
parent_scanner
.
context
self
.
included_files
=
parent_scanner
.
included_files
self
.
included_files
=
parent_scanner
.
included_files
self
.
compile_time_env
=
parent_scanner
.
compile_time_env
self
.
compile_time_env
=
parent_scanner
.
compile_time_env
self
.
compile_time_eval
=
parent_scanner
.
compile_time_eval
self
.
compile_time_eval
=
parent_scanner
.
compile_time_eval
self
.
compile_time_expr
=
parent_scanner
.
compile_time_expr
self
.
compile_time_expr
=
parent_scanner
.
compile_time_expr
if
parent_scanner
.
async_enabled
:
self
.
enter_async
()
else
:
else
:
self
.
context
=
context
self
.
context
=
context
self
.
included_files
=
scope
.
included_files
self
.
included_files
=
scope
.
included_files
...
@@ -338,17 +351,11 @@ class PyrexScanner(Scanner):
...
@@ -338,17 +351,11 @@ class PyrexScanner(Scanner):
self
.
compile_time_env
.
update
(
context
.
options
.
compile_time_env
)
self
.
compile_time_env
.
update
(
context
.
options
.
compile_time_env
)
self
.
parse_comments
=
parse_comments
self
.
parse_comments
=
parse_comments
self
.
source_encoding
=
source_encoding
self
.
source_encoding
=
source_encoding
if
filename
.
is_python_file
():
self
.
in_python_file
=
True
self
.
keywords
=
set
(
py_reserved_words
)
else
:
self
.
in_python_file
=
False
self
.
keywords
=
set
(
pyx_reserved_words
)
self
.
trace
=
trace_scanner
self
.
trace
=
trace_scanner
self
.
indentation_stack
=
[
0
]
self
.
indentation_stack
=
[
0
]
self
.
indentation_char
=
None
self
.
indentation_char
=
None
self
.
bracket_nesting_level
=
0
self
.
bracket_nesting_level
=
0
self
.
async_enabled
=
0
self
.
begin
(
'INDENT'
)
self
.
begin
(
'INDENT'
)
self
.
sy
=
''
self
.
sy
=
''
self
.
next
()
self
.
next
()
...
...
tests/run/fstring.pyx
View file @
e989f760
...
@@ -513,3 +513,21 @@ def percent_s_unicode(u, int i):
...
@@ -513,3 +513,21 @@ def percent_s_unicode(u, int i):
x
\
u0194
z-12
x
\
u0194
z-12
"""
"""
return
u"%s-%d"
%
(
u
,
i
)
return
u"%s-%d"
%
(
u
,
i
)
########################################
# await inside f-string
def
test_await_inside_f_string
():
"""
>>> test_await_inside_f_string()
PARSED_SUCCESSFULLY
"""
async
def
f
():
return
"some value"
async
def
main
():
print
(
f"
{
await
f
()
}
"
)
print
(
"PARSED_SUCCESSFULLY"
)
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