GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-112301: Use literal format strings in unicode_fromformat_arg by encukou · Pull Request #124203 · python/cpython

Conversation

@encukou

@encukou encukou commented Sep 18, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This switches sprintf format strings in unicode_fromformat_arg to compile-time literals, avoiding -Wformat-nonliteral warnings and maybe even allowing optimizing the sprintf calls.

The macros aren't too readable so I'm generous with comments.

(Another option would be code generation, see the first commit.)

  • Issue: Consider applying flags for warnings about potential security issues #112301

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
encukou added 2 commits September 18, 2024 10:03
@encukou
Generated code
1ebc9ee
@encukou
Macros
b562a43
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 18, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 18, 2024
Consider applying flags for warnings about potential security issues #112301
Closed
@encukou encukou mentioned this pull request Sep 18, 2024
gh-112301: Add -Wformat=2 compiler option to NODIST #122474
Closed
@rruuaanng

rruuaanng commented Sep 18, 2024

Copy link
Copy Markdown
Contributor

Maybe you should add NEWS.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou encukou added the skip news label Sep 18, 2024
@vstinner

vstinner commented Sep 18, 2024

Copy link
Copy Markdown
Member

Maybe you should add NEWS.

This change doesn't impact end users. I don't think that a NEWS entry is needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Sep 18, 2024
View reviewed changes
Comment thread Objects/unicodeobject.c Outdated
sprintf(buffer, fmt, va_arg(*vargs, int)) :
sprintf(buffer, fmt, va_arg(*vargs, unsigned int));
break;
case F_LONG: DO_SPRINTS("l", long, unsigned long)

@vstinner vstinner Sep 18, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you put the break here? Something like:

Suggested change
case F_LONG: DO_SPRINTS("l", long, unsigned long)
case F_LONG: DO_SPRINTS("l", long, unsigned long); break;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Sep 24, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

OK!
One line is 85 characters now, but I think it's most readable this way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@encukou
Put ;break; in the switch
218929c
vstinner
vstinner approved these changes Sep 24, 2024
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 24, 2024
@encukou
encukou merged commit da5855e into python:main Sep 25, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 25, 2024
@encukou
encukou deleted the sizemod branch September 25, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@encukou @rruuaanng @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.