Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,17 @@ def main():
with open(args[0], 'rb') as f:
func(f, sys.stdout.buffer)
else:
func(sys.stdin.buffer, sys.stdout.buffer)
if sys.stdin.isatty():
# gh-gh-138775: read input data at once when reading from stdin
# This allows proper handling of EOF (Ctrl+D)
input_data = sys.stdin.buffer.read()
if input_data:
import io
input_buffer = io.BytesIO(input_data)
func(input_buffer, sys.stdout.buffer)
else:
# keep the old behaviour for non-interactive input
func(sys.stdin.buffer, sys.stdout.buffer)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix: handle "python -m base64" stdin correct with EOF single.
Loading