Commit 97689343 authored by Stefan Behnel's avatar Stefan Behnel

Add tests that f-strings are rejected in nogil sections.

parent aed19e49
...@@ -8,14 +8,14 @@ cdef void g(int x) nogil: ...@@ -8,14 +8,14 @@ cdef void g(int x) nogil:
cdef object z cdef object z
z = None z = None
cdef void h(int x) nogil: cdef void h(int x) nogil: # allowed
p() p()
cdef object p() nogil: cdef object p() nogil:
pass pass
cdef void r() nogil: cdef void r() nogil: # allowed
q() q() # allowed
cdef object m(): cdef object m():
cdef object x, y = 0, obj cdef object x, y = 0, obj
...@@ -23,11 +23,11 @@ cdef object m(): ...@@ -23,11 +23,11 @@ cdef object m():
global fred global fred
q() q()
with nogil: with nogil:
r() r() # allowed to call plain C functions
q() q()
i = 42 i = 42 # allowed with type inference
obj = None obj = None
17L 17L # allowed
<object>7j <object>7j
help help
xxx = `"Hello"` xxx = `"Hello"`
...@@ -45,7 +45,7 @@ cdef object m(): ...@@ -45,7 +45,7 @@ cdef object m():
{x, y} {x, y}
obj and x obj and x
t(obj) t(obj)
# f(42) # Cython handles this internally f(42)
x + obj x + obj
-obj -obj
x = y = obj x = y = obj
...@@ -90,8 +90,13 @@ def bare_pyvar_name(object x): ...@@ -90,8 +90,13 @@ def bare_pyvar_name(object x):
with nogil: with nogil:
x x
# For m(), the important thing is that there are errors on all lines in the range 23-69 cdef int fstrings(int x, object obj) nogil except -1:
# except these: 29, 34, 44, 56, 58, 60, 62-64 f"" # allowed
f"a" # allowed
f"a"f"b" # allowed
f"{x}"
f"{obj}"
_ERRORS = u""" _ERRORS = u"""
4:5: Function with Python return type cannot be declared nogil 4:5: Function with Python return type cannot be declared nogil
...@@ -133,6 +138,7 @@ _ERRORS = u""" ...@@ -133,6 +138,7 @@ _ERRORS = u"""
46:12: Discarding owned Python object not allowed without gil 46:12: Discarding owned Python object not allowed without gil
46:12: Truth-testing Python object not allowed without gil 46:12: Truth-testing Python object not allowed without gil
47:10: Python type test not allowed without gil 47:10: Python type test not allowed without gil
48:9: Discarding owned Python object not allowed without gil
49:10: Discarding owned Python object not allowed without gil 49:10: Discarding owned Python object not allowed without gil
49:10: Operation not allowed without gil 49:10: Operation not allowed without gil
50:8: Discarding owned Python object not allowed without gil 50:8: Discarding owned Python object not allowed without gil
...@@ -158,4 +164,9 @@ _ERRORS = u""" ...@@ -158,4 +164,9 @@ _ERRORS = u"""
63:24: Coercion from Python not allowed without the GIL 63:24: Coercion from Python not allowed without the GIL
65:8: Try-except statement not allowed without gil 65:8: Try-except statement not allowed without gil
86:8: For-loop using object bounds or target not allowed without gil 86:8: For-loop using object bounds or target not allowed without gil
97:4: Discarding owned Python object not allowed without gil
97:4: String formatting not allowed without gil
98:4: Discarding owned Python object not allowed without gil
98:4: String formatting not allowed without gil
""" """
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment