mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-138775: fix handle python -m base64 stdin correct with EOF signal (GH-138776) (#141433)
gh-138775: fix handle `python -m base64` stdin correct with EOF signal (GH-138776)
* fix: handle stdin correct with EOF single.
* fix: flollow the comments when pipe stdin use buffer
* Apply suggestions from code review
* fix: apply review comments in Lib/base64.py
* fix: address comments
* Reword comment and NEWS entry.
---------
(cherry picked from commit f5c2a41f9a)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: yihong <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
b28ba31c69
commit
54f620cc7f
2 changed files with 10 additions and 1 deletions
|
|
@ -607,7 +607,14 @@ def main():
|
||||||
with open(args[0], 'rb') as f:
|
with open(args[0], 'rb') as f:
|
||||||
func(f, sys.stdout.buffer)
|
func(f, sys.stdout.buffer)
|
||||||
else:
|
else:
|
||||||
func(sys.stdin.buffer, sys.stdout.buffer)
|
if sys.stdin.isatty():
|
||||||
|
# gh-138775: read terminal input data all at once to detect EOF
|
||||||
|
import io
|
||||||
|
data = sys.stdin.buffer.read()
|
||||||
|
buffer = io.BytesIO(data)
|
||||||
|
else:
|
||||||
|
buffer = sys.stdin.buffer
|
||||||
|
func(buffer, sys.stdout.buffer)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Use of ``python -m`` with :mod:`base64` has been fixed to detect input from a
|
||||||
|
terminal so that it properly notices EOF.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue