Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.6k
Description
I am getting an impossible syntax error:
SyntaxError: Format strings are only supported in Python 3.6 and greater
Running Python version 3.8.3 and Cython version 0.29.20 and using language level set to 3. Havenot installed any previous versions of python on my machine. I have programmed thousands of lines in cython and use f-strings constantly. The problem occurred when I defined a class (that incorporated f-strings) in a multi-line string, and created it using the exec() function. This class was pretty complicated so I had thought perhaps I did something wrong so I created a test and got thesame error. Which indicated to me that it is a problem with cython itself, not the code I had written.
Test code:
# Same output if you remove the cdef and just use normal python variablescdef str test_code = """class Test: def __init__(self): var1,var2 = 123,321 self.test = f"{var1}, {var2}""""cdef dict d = {}exec(test_code, locals(), d)Test = d['Test']# Results in the same error described earlier