New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bytecode for empty f-string != bytecode for empty normal string #99606
Comments
Why do you call that a bug? And why would you write |
Aren't they the same thing so shouldn't they have the same bytecode? It's pretty inconsistent with |
The intention was that an f-string without any substitutions would be equivalent to a normal string. These examples are 3.12+. It's true for non-empty strings, it should probably be the same for empty strings. Not that I think it's a big deal. >>> dis.dis("f'x'")
0 0 RESUME 0
1 2 LOAD_CONST 0 ('x')
4 RETURN_VALUE
>>> dis.dis("'x'")
0 0 RESUME 0
1 2 LOAD_CONST 0 ('x')
4 RETURN_VALUE
>>> dis.dis("f''")
0 0 RESUME 0
1 2 BUILD_STRING 0
4 RETURN_VALUE
>>> dis.dis("''")
0 0 RESUME 0
1 2 LOAD_CONST 0 ('')
4 RETURN_VALUE |
…o that of a normal empty string
… of a normal empty string (#112407)
…o that of a normal empty string (python#112407)
Bug report
The bytecode for an empty f-string does not match the bytecode for an empty normal string.
Output:
Environment
3.11, 3.12.0a2
Linked PRs
The text was updated successfully, but these errors were encountered: