Skip to content

Conversation

@superboy-zjc
Copy link
Contributor

@superboy-zjc superboy-zjc commented Jan 9, 2026

Fix a inconsistency issue in io.BytesIO.write() where the buffer was exported twice, which could lead to unexpected data overwrites and position drift when the buffer changes between exports.

Fix a inconsistency issue in io.BytesIO.write() where the buffer was exported twice, which could lead to unexpected data overwrites and position drift when the buffer changes between exports.
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. The NEWS entry can be enhanced, but I cannot propose a better description.

@vstinner vstinner merged commit c461aa9 into python:main Jan 15, 2026
50 checks passed
@vstinner vstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jan 15, 2026
@miss-islington-app
Copy link

Thanks @superboy-zjc for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @superboy-zjc for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app
Copy link

Sorry, @superboy-zjc and @vstinner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c461aa99e2fabbaf5859c0a8a93e08306ee8115d 3.13

@miss-islington-app
Copy link

Sorry, @superboy-zjc and @vstinner, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c461aa99e2fabbaf5859c0a8a93e08306ee8115d 3.14

@bedevere-app
Copy link

bedevere-app bot commented Jan 15, 2026

GH-143872 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 15, 2026
@vstinner
Copy link
Member

I backported the change to 3.14: #143872.

@vstinner vstinner removed the needs backport to 3.13 bugs and security fixes label Jan 15, 2026
@vstinner
Copy link
Member

Merged, thanks for your contribution @superboy-zjc.

vstinner pushed a commit to vstinner/cpython that referenced this pull request Jan 15, 2026
…thon#143629)

Fix an inconsistency issue in io.BytesIO.write() where the buffer was exported
twice, which could lead to unexpected data overwrites and position drift when
the buffer changes between exports.

(cherry picked from commit c461aa9)
@serhiy-storchaka
Copy link
Member

LGTM. 👍

vstinner added a commit that referenced this pull request Jan 15, 2026
…143629) (#143872)

gh-143602: Fix duplicate buffer exports in io.BytesIO.write (#143629)

Fix an inconsistency issue in io.BytesIO.write() where the buffer was exported
twice, which could lead to unexpected data overwrites and position drift when
the buffer changes between exports.

(cherry picked from commit c461aa9)

Co-authored-by: zhong <[email protected]>
@bedevere-bot
Copy link

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

Hi! The buildbot ARM64 macOS 3.14 (tier-2) has failed when building commit 1241432.

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/#/builders/1772/builds/811) and take a look at the build logs.
  4. Check if the failure is related to this commit (1241432) 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/#/builders/1772/builds/811

Failed tests:

  • test_urllib2net

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

==

Click to see traceback logs
remote: Enumerating objects: 11, done.        
remote: Counting objects:  25% (1/4)        
remote: Counting objects:  50% (2/4)        
remote: Counting objects:  75% (3/4)        
remote: Counting objects: 100% (4/4)        
remote: Counting objects: 100% (4/4), done.        
remote: Compressing objects:  33% (1/3)        
remote: Compressing objects:  66% (2/3)        
remote: Compressing objects: 100% (3/3)        
remote: Compressing objects: 100% (3/3), done.        
remote: Total 11 (delta 1), reused 1 (delta 1), pack-reused 7 (from 2)        
From https://github.com/python/cpython
 * branch                    3.14       -> FETCH_HEAD
Note: switching to '1241432150f6342e3d38c5a80a19c8c157a4ebe8'.

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 1241432150f [3.14] gh-143602: Fix duplicate buffer exports in io.BytesIO.write (#143629) (#143872)
Switched to and reset branch '3.14'

make: *** [buildbottest] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants