Skip to content

Commit 16e302c

Browse files
committed
fix: handle stdin correct with EOF single.
Signed-off-by: yihong0618 <[email protected]>
1 parent d0c9943 commit 16e302c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/base64.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,13 @@ def main():
601601
with open(args[0], 'rb') as f:
602602
func(f, sys.stdout.buffer)
603603
else:
604-
func(sys.stdin.buffer, sys.stdout.buffer)
604+
# Read all input data at once when reading from stdin
605+
# This allows proper handling of EOF (Ctrl+D)
606+
input_data = sys.stdin.buffer.read()
607+
if input_data:
608+
import io
609+
input_buffer = io.BytesIO(input_data)
610+
func(input_buffer, sys.stdout.buffer)
605611

606612

607613
if __name__ == '__main__':
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix: handle "python -m base64" stdin correct with EOF single.

0 commit comments

Comments
 (0)