Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Invalid Error With Support Of F-Strings Using exec() Function #3695

Closed
@DeathDragon7050

Description

@DeathDragon7050

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp