]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] GH-134453: Fix subprocess memoryview input handling on POSIX (GH-134949) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 29 Nov 2025 04:52:14 +0000 (05:52 +0100)
committerGitHub <noreply@github.com>
Sat, 29 Nov 2025 04:52:14 +0000 (04:52 +0000)
commitc1d3e2523b9f85c21489accb3b193035d9d943f4
tree2a92f99d3329f47b0701c92c165d68cd7369fc50
parenta1dd2480226370b6924dbd8a59f9c86dc856047b
[3.14] GH-134453: Fix subprocess memoryview input handling on POSIX (GH-134949) (#142062)

GH-134453: Fix subprocess memoryview input handling on POSIX (GH-134949)

Fix inconsistent subprocess.Popen.communicate() behavior between Windows
and POSIX when using memoryview objects with non-byte elements as input.

On POSIX systems, the code was incorrectly comparing bytes written against
element count instead of byte count, causing data truncation for large
inputs with non-byte element types.

Changes:
- Cast memoryview inputs to byte view when input is already a memoryview
- Fix progress tracking to use len(input_view) instead of len(self._input)
- Add comprehensive test coverage for memoryview inputs

🤖 Generated with [Claude Code](https://claude.ai/code)

* old-man-yells-at-ReST
* Update 2025-05-30-18-37-44.gh-issue-134453.kxkA-o.rst
* assertIsNone review feedback
* fix memoryview_nonbytes test to fail without our fix on main, and have a nicer error.

Thanks to Peter Bierma @ZeroIntensity for the code review.
(cherry picked from commit cc6bc4c97f7be5b401a91119ba603e6c1a07c99b)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/NEWS.d/next/Library/2025-05-30-18-37-44.gh-issue-134453.kxkA-o.rst [new file with mode: 0644]