Skip to content

Commit 94c716d

Browse files
yihong0618picnixz
andauthored
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent 22f8939 commit 94c716d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Lib/base64.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,10 @@ def main():
602602
func(f, sys.stdout.buffer)
603603
else:
604604
if sys.stdin.isatty():
605-
# gh-gh-138775: read input data at once when reading from stdin
606-
# This allows proper handling of EOF (Ctrl+D)
607-
input_data = sys.stdin.buffer.read()
608-
if input_data:
609-
import io
610-
input_buffer = io.BytesIO(input_data)
611-
func(input_buffer, sys.stdout.buffer)
605+
# gh-138775: read input data at once when reading from stdin.
606+
import io
607+
data = sys.stdin.buffer.read()
608+
func(io.BytesIO(data), sys.stdout.buffer)
612609
else:
613610
# keep the old behaviour for non-interactive input
614611
func(sys.stdin.buffer, sys.stdout.buffer)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix: handle "python -m base64" stdin correct with EOF single.
1+
:mod:`base64`: fix reading from stdin for the command-line interface.

0 commit comments

Comments
 (0)