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-106168: Revert the "size before item" setting by scoder · Pull Request #111683 · python/cpython

Conversation

@scoder

@scoder scoder commented Nov 3, 2023 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Update the size only after setting the item, to avoid temporary inconsistencies.

Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.

  • Issue: C API: Check in PyTuple_SET_ITEM() and PyList_SET_ITEM() #106168

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@scoder
pythongh-106168: Update the size only after setting the item, to avoi…
6b19abb
…d temporary inconsistencies.

Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
@scoder scoder added the skip news label Nov 3, 2023
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 3, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 3, 2023
C API: Check in PyTuple_SET_ITEM() and PyList_SET_ITEM() #106168
Closed
@scoder
scoder requested a review from vstinner November 3, 2023 08:42
vstinner
vstinner approved these changes Nov 3, 2023
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.

With the GIL, _PyList_AppendTakeRef() and list_extend() change are not important: setting the item first or setting the size first, both are safe. But when I read the code and attempt to imagine a "free threading" (NoGIL) world, yeah, I see that the Python 3.12 code looks more correct: first set the item, then announce that the list is one item longer.

Moreover I only made these 2 changes when PyList_SET_ITEM() rejected writes outside 0..size range, which is no longer the case. So I'm fine with reverting these changes.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/whatsnew/3.13.rst
assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and
:c:func:`PyList_SET_ITEM` now check the index argument with an assertion.
If the assertion fails in :c:func:`PyTuple_SET_ITEM`, make sure that the
tuple size is set before.

@vstinner vstinner Nov 3, 2023

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 was sure that I had issues with PyTuple_SET_ITEM() and code setting the tuple size just after that. But I checked again https://github.com/python/cpython/pull/106164/files and I was wrong: the problem was specific to lists, and your change (allow write into 0..allocated range) makes this sentence outdated. I'm fine with removing it.

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 Nov 3, 2023
@vstinner
vstinner enabled auto-merge (squash) November 3, 2023 11:02
@vstinner
vstinner merged commit 24ddaee into python:main Nov 3, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 3, 2023
@bedevere-bot

bedevere-bot commented Nov 3, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x SLES 3.x has failed when building commit 24ddaee.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/540/builds/7057) and take a look at the build logs.
  4. Check if the failure is related to this commit (24ddaee) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/540/builds/7057

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 19, done.        
remote: Counting objects:   5% (1/19)        
remote: Counting objects:  10% (2/19)        
remote: Counting objects:  15% (3/19)        
remote: Counting objects:  21% (4/19)        
remote: Counting objects:  26% (5/19)        
remote: Counting objects:  31% (6/19)        
remote: Counting objects:  36% (7/19)        
remote: Counting objects:  42% (8/19)        
remote: Counting objects:  47% (9/19)        
remote: Counting objects:  52% (10/19)        
remote: Counting objects:  57% (11/19)        
remote: Counting objects:  63% (12/19)        
remote: Counting objects:  68% (13/19)        
remote: Counting objects:  73% (14/19)        
remote: Counting objects:  78% (15/19)        
remote: Counting objects:  84% (16/19)        
remote: Counting objects:  89% (17/19)        
remote: Counting objects:  94% (18/19)        
remote: Counting objects: 100% (19/19)        
remote: Counting objects: 100% (19/19), done.        
remote: Compressing objects:  12% (1/8)        
remote: Compressing objects:  25% (2/8)        
remote: Compressing objects:  37% (3/8)        
remote: Compressing objects:  50% (4/8)        
remote: Compressing objects:  62% (5/8)        
remote: Compressing objects:  75% (6/8)        
remote: Compressing objects:  87% (7/8)        
remote: Compressing objects: 100% (8/8)        
remote: Compressing objects: 100% (8/8), done.        
remote: Total 10 (delta 9), reused 2 (delta 2), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '24ddaee5ca112063b460e72d31b3da551a02bf0a'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 24ddaee5ca gh-106168: Revert the "size before item" setting (#111683)
Switched to and reset branch 'main'

make: *** [Makefile:2062: buildbottest] Error 3
All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Nov 3, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD 3.x has failed when building commit 24ddaee.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1223/builds/661) and take a look at the build logs.
  4. Check if the failure is related to this commit (24ddaee) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1223/builds/661

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 19, done.        
remote: Counting objects:   5% (1/19)        
remote: Counting objects:  10% (2/19)        
remote: Counting objects:  15% (3/19)        
remote: Counting objects:  21% (4/19)        
remote: Counting objects:  26% (5/19)        
remote: Counting objects:  31% (6/19)        
remote: Counting objects:  36% (7/19)        
remote: Counting objects:  42% (8/19)        
remote: Counting objects:  47% (9/19)        
remote: Counting objects:  52% (10/19)        
remote: Counting objects:  57% (11/19)        
remote: Counting objects:  63% (12/19)        
remote: Counting objects:  68% (13/19)        
remote: Counting objects:  73% (14/19)        
remote: Counting objects:  78% (15/19)        
remote: Counting objects:  84% (16/19)        
remote: Counting objects:  89% (17/19)        
remote: Counting objects:  94% (18/19)        
remote: Counting objects: 100% (19/19)        
remote: Counting objects: 100% (19/19), done.        
remote: Compressing objects:  12% (1/8)        
remote: Compressing objects:  25% (2/8)        
remote: Compressing objects:  37% (3/8)        
remote: Compressing objects:  50% (4/8)        
remote: Compressing objects:  62% (5/8)        
remote: Compressing objects:  75% (6/8)        
remote: Compressing objects:  87% (7/8)        
remote: Compressing objects: 100% (8/8)        
remote: Compressing objects: 100% (8/8), done.        
remote: Total 10 (delta 9), reused 2 (delta 2), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '24ddaee5ca112063b460e72d31b3da551a02bf0a'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 24ddaee5ca gh-106168: Revert the "size before item" setting (#111683)
Switched to and reset branch 'main'
All reactions

Sorry, something went wrong.

Uh oh!

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

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@scoder @aisk
pythongh-106168: Revert the "size before item" setting (python#111683)
1193f1d
pythongh-106168: Update the size only after setting the item, to avoid temporary inconsistencies.
Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@scoder @Glyphack
pythongh-106168: Revert the "size before item" setting (python#111683)
edfc396
pythongh-106168: Update the size only after setting the item, to avoid temporary inconsistencies.
Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
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

@scoder @bedevere-bot @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.