diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-05 10:27:45 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-05 10:27:45 +0200 |
commit | 976893432edde8dcecca2b935399104dd74c27be (patch) | |
tree | 504525eb668e75d21b22d3a4402582f376d70372 | |
parent | aed19e492491c26ef6dcb60f81de79b8361d4a57 (diff) | |
download | cython-976893432edde8dcecca2b935399104dd74c27be.tar.gz |
Add tests that f-strings are rejected in nogil sections.
-rw-r--r-- | tests/errors/nogil.pyx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tests/errors/nogil.pyx b/tests/errors/nogil.pyx index 721c1c5ed..48cf66aa4 100644 --- a/tests/errors/nogil.pyx +++ b/tests/errors/nogil.pyx @@ -8,14 +8,14 @@ cdef void g(int x) nogil: cdef object z z = None -cdef void h(int x) nogil: +cdef void h(int x) nogil: # allowed p() cdef object p() nogil: pass -cdef void r() nogil: - q() +cdef void r() nogil: # allowed + q() # allowed cdef object m(): cdef object x, y = 0, obj @@ -23,11 +23,11 @@ cdef object m(): global fred q() with nogil: - r() + r() # allowed to call plain C functions q() - i = 42 + i = 42 # allowed with type inference obj = None - 17L + 17L # allowed <object>7j help xxx = `"Hello"` @@ -45,7 +45,7 @@ cdef object m(): {x, y} obj and x t(obj) -# f(42) # Cython handles this internally + f(42) x + obj -obj x = y = obj @@ -90,8 +90,13 @@ def bare_pyvar_name(object x): with nogil: x -# For m(), the important thing is that there are errors on all lines in the range 23-69 -# except these: 29, 34, 44, 56, 58, 60, 62-64 +cdef int fstrings(int x, object obj) nogil except -1: + f"" # allowed + f"a" # allowed + f"a"f"b" # allowed + f"{x}" + f"{obj}" + _ERRORS = u""" 4:5: Function with Python return type cannot be declared nogil @@ -133,6 +138,7 @@ _ERRORS = u""" 46:12: Discarding owned 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 +48:9: 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 50:8: Discarding owned Python object not allowed without gil @@ -158,4 +164,9 @@ _ERRORS = u""" 63:24: Coercion from Python not allowed without the GIL 65:8: Try-except statement 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 """ |