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 — Add a warning message about PyOS_snprintf by eric-wieser · Pull Request #95993 · python/cpython

Conversation

@eric-wieser

@eric-wieser eric-wieser commented Aug 15, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

The top google result for "determine sprintf buffer size" is https://stackoverflow.com/a/3923207/102441, which advocates code along the lines of

int size = snprintf(NULL, 0, "%d", 132);
char * a = malloc(size + 1);
sprintf(a, "%d", 132);

Unfortunately, this does not work for PyOS_snprintf, as it includes an assert to ensure the arguments are not NULL and 0.

This PR simply documents this limitation.

Sorry, something went wrong.

Uh oh!

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

All reactions
@eric-wieser
Add a warning message about PyOS_snprintf
7c5d9f9
@bedevere-bot bedevere-bot added the awaiting review label Aug 15, 2022
@eric-wieser eric-wieser mentioned this pull request Aug 15, 2022
gh-76961: Fix the PEP3118 format string for ctypes.Structure #5561
Merged
@JelleZijlstra JelleZijlstra added skip issue skip news needs backport to 3.10 needs backport to 3.11 only security fixes labels Oct 7, 2022
JelleZijlstra
JelleZijlstra approved these changes Oct 7, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Oct 7, 2022
@JelleZijlstra
JelleZijlstra merged commit c7b2204 into python:main Oct 7, 2022
@miss-islington

miss-islington commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

Thanks @eric-wieser for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the awaiting merge label Oct 7, 2022
@bedevere-bot

bedevere-bot commented Oct 7, 2022

Copy link
Copy Markdown

GH-98047 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Oct 7, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2022
@eric-wieser @miss-islington
Add a warning message about PyOS_snprintf (pythonGH-95993)
48d6d57
(cherry picked from commit c7b2204)

Co-authored-by: Eric Wieser <[email protected]>
@bedevere-bot

bedevere-bot commented Oct 7, 2022

Copy link
Copy Markdown

GH-98048 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Oct 7, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2022
@eric-wieser @miss-islington
Add a warning message about PyOS_snprintf (pythonGH-95993)
415244f
(cherry picked from commit c7b2204)

Co-authored-by: Eric Wieser <[email protected]>
miss-islington added a commit that referenced this pull request Oct 7, 2022
@miss-islington @eric-wieser
Add a warning message about PyOS_snprintf (GH-95993)
0a84b7a
(cherry picked from commit c7b2204)

Co-authored-by: Eric Wieser <[email protected]>
miss-islington added a commit that referenced this pull request Oct 7, 2022
@miss-islington @eric-wieser
Add a warning message about PyOS_snprintf (GH-95993)
90f2c79
(cherry picked from commit c7b2204)

Co-authored-by: Eric Wieser <[email protected]>
mpage pushed a commit to mpage/cpython that referenced this pull request Oct 11, 2022
@eric-wieser @mpage
Add a warning message about PyOS_snprintf (python#95993)
358e173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

skip issue 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.

4 participants

@eric-wieser @miss-islington @bedevere-bot @JelleZijlstra
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 01402503 — 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.