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

gh-70278: Fix PyUnicode_FromFormat() with precision for %s and %V#120365

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedJun 11, 2024
edited by bedevere-appbot
Loading

PyUnicode_FromFormat() no longer produces the ending \ufffd character for truncated C string when use precision with %s and %V. It now truncates the string before the start of truncated multibyte sequences.

PyUnicode_FromFormat() no longer produces the ending \ufffdcharacter for truncated C string when use precision with %s and %V.It now truncates the string before the start of truncated multibyte sequences.
while (length<precision&&str[length]) {
length++;
}
pconsumed= (length<precision) ?NULL :&consumed;
Copy link
Member

@vstinnervstinnerJun 12, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add a comment explaining why you set pconsumed? Explain the expected behavior of truncating incomplete sequence at the end, but still replace invalid sequence in the middle. Something like that :-) You can add a reference to the issuegh-70278.

@vstinner
Copy link
Member

Can you try to add an unit test?

@serhiy-storchaka
Copy link
MemberAuthor

There are new tests in this PR. What other cases do you want to test?

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

For tests, GitHub didn't show me the whole diff when I clicked on a notification. I'm always confused by the UI, sorry.

@serhiy-storchakaserhiy-storchaka merged commit6eb23b1 intopython:mainJun 24, 2024
@serhiy-storchakaserhiy-storchaka deleted the PyUnicode_FromFormat-truncate branchJune 24, 2024 15:07
mrahtz pushed a commit to mrahtz/cpython that referenced this pull requestJun 30, 2024
…%V (pythonGH-120365)PyUnicode_FromFormat() no longer produces the ending \ufffdcharacter for truncated C string when use precision with %s and %V.It now truncates the string before the start of truncated multibyte sequences.
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
…%V (pythonGH-120365)PyUnicode_FromFormat() no longer produces the ending \ufffdcharacter for truncated C string when use precision with %s and %V.It now truncates the string before the start of truncated multibyte sequences.
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
…%V (pythonGH-120365)PyUnicode_FromFormat() no longer produces the ending \ufffdcharacter for truncated C string when use precision with %s and %V.It now truncates the string before the start of truncated multibyte sequences.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@serhiy-storchaka@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp