Bug report
Bug description:
When using an f-string in combination with lambda functions that return non-ASCII characters, either a UnicodeDecodeError or a SystemError is raised, depending on the specific modification made to the code. These errors do not occur consistently, but rather vary based on how the lambdas and string content are altered.
Steps to Reproduce
def test1(foo, bar):
return ""
def test2():
return f"{test1(
foo=lambda: '、、、、、、、、、、、、、、、、、',
bar=lambda: 'abcdefghijklmnopqrstuvwxyz 123456789 123456789',
)}"
Run the code with python <file.py>, which triggers the following error:
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 28-29: unexpected end of data
Expected Behavior
The code should execute without raising any errors.
Actual Behavior
The following behaviors are observed when making the specified modifications. Each of these cases is independent:
- Removing one
、 character from the first string (foo): No error.
- Removing all
、 characters from the first string: SystemError: Negative size passed to PyUnicode_New.
- Removing
foo= (i.e., not passing foo by keyword): No error.
- Removing
lambda: (i.e., making either argument or both into a str type instead of a Callable[[], str]): No error.
- Removing any character from the second string (
bar): No error.
Other Relevant Information
The bug does not reproduce in Python 3.13.1, but it does reproduce in Python 3.13.2 and 3.12.9.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
When using an
f-stringin combination withlambdafunctions that return non-ASCII characters, either aUnicodeDecodeErroror aSystemErroris raised, depending on the specific modification made to the code. These errors do not occur consistently, but rather vary based on how the lambdas and string content are altered.Steps to Reproduce
Run the code with
python <file.py>, which triggers the following error:Expected Behavior
The code should execute without raising any errors.
Actual Behavior
The following behaviors are observed when making the specified modifications. Each of these cases is independent:
、character from the first string (foo): No error.、characters from the first string:SystemError: Negative size passed to PyUnicode_New.foo=(i.e., not passingfooby keyword): No error.lambda:(i.e., making either argument or both into astrtype instead of aCallable[[], str]): No error.bar): No error.Other Relevant Information
The bug does not reproduce in Python 3.13.1, but it does reproduce in Python 3.13.2 and 3.12.9.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs