]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-134453: Fix subprocess memoryview input handling on POSIX (GH-134949)
authorGregory P. Smith <68491+gpshead@users.noreply.github.com>
Sat, 29 Nov 2025 04:25:06 +0000 (20:25 -0800)
committerGitHub <noreply@github.com>
Sat, 29 Nov 2025 04:25:06 +0000 (04:25 +0000)
commitcc6bc4c97f7be5b401a91119ba603e6c1a07c99b
treef22685eeac0410e28dfc8c24ceb1c6a33517d09b
parent526d7a8bb47bd8ff58c829c30384cd70cc5d0747
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)

Co-Authored-By: Claude <noreply@anthropic.com>
* 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.
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]