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 — [3.14] gh-146056: Fix repr() for lists and tuples containing NULLs (GH-146129) (alt) by serhiy-storchaka · Pull Request #146204 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Mar 20, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

(cherry picked from commit 0f2246b)

This is an alternative to #146155 which only fixes PyUnicodeWriter_WriteRepr() for internal use, leaving users with the broken variant.

  • Issue: Crash in repr() for lists containing NULLs #146056

📚 Documentation preview 📚: https://cpython-previews--146204.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka @vstinner
[3.14] pythongh-146056: Fix list.__repr__() for lists containing NULLs (
fec7f55
pythonGH-146129)

(cherry picked from commit 0f2246b)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@serhiy-storchaka
serhiy-storchaka requested a review from vstinner March 20, 2026 11:47
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 only security fixes label Mar 20, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Mar 20, 2026
Crash in repr() for lists containing NULLs #146056
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 20, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Mar 20, 2026
gh-146056: Fix repr() for lists and tuples containing NULLs #146129
Merged
@serhiy-storchaka
Merge branch '3.14' into list-repr-null-3.14
a4ea518
@serhiy-storchaka serhiy-storchaka changed the title [3.14] gh-146056: Fix list.__repr__() for lists containing NULLs (GH-146129) [3.14] gh-146056: Fix list.__repr__() for lists containing NULLs (GH-146129) (alt) Mar 20, 2026
vstinner
vstinner reviewed Mar 20, 2026
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.

I don't think that this hack is needed. I would prefer to only change tuple_repr() and list_repr().

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Misc/NEWS.d/next/C_API/2026-03-18-20-18-59.gh-issue-146056.nnZIgp.rst Outdated
@@ -0,0 +1 @@
:c:func:`PyUnicodeWriter_WriteRepr` now supports ``NULL`` argument.

@vstinner vstinner Mar 20, 2026

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.

This is no longer true.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Include/cpython/unicodeobject.h
PyObject *obj);
#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE)
#define PyUnicodeWriter_WriteRepr _PyUnicodeWriter_WriteReprTrue
#endif

@vstinner vstinner Mar 20, 2026

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.

It looks like a bad hack to me. I don't think that it's needed: only tuple_repr() and list_repr() should be modified to accept NULL: #146155 (comment), other functions cannot call PyUnicodeWriter_WriteRepr() with NULL.

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Mar 20, 2026

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.

I tried to minimize the diff. If you prefer, we can simply replace PyUnicodeWriter_WriteRepr with _PyUnicodeWriter_WriteReprTrue. This will make future backports more difficult.

We cannot be sure that this is not needed until we analyze every use of PyUnicodeWriter_WriteRepr. This will take a time. Even if it is not needed right now, it can be needed after future backports.

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka
Delete Misc/NEWS.d/next/C_API/2026-03-18-20-18-59.gh-issue-146056.nnZ…
5e3172c
…Igp.rst
@serhiy-storchaka serhiy-storchaka changed the title [3.14] gh-146056: Fix list.__repr__() for lists containing NULLs (GH-146129) (alt) [3.14] gh-146056: Fix repr() for lists and tuples containing NULLs (GH-146129) (alt) Mar 20, 2026
@serhiy-storchaka serhiy-storchaka closed this Mar 22, 2026
@serhiy-storchaka
serhiy-storchaka deleted the list-repr-null-3.14 branch March 22, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments

Uh oh!

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

Assignees

No one assigned

Labels

awaiting core review needs backport to 3.13 only security fixes

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.

2 participants

@serhiy-storchaka @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 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.