pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/f5c2a41f9a6b3be95c5be9dbae0a4a3342d356dc

gh-138775: fix handle `python -m base64` stdin correct with EOF signa… · python/cpython@f5c2a41 · GitHub
Skip to content

Commit f5c2a41

Browse files
yihong0618picnixzZeroIntensitygpshead
authored
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. --------- Signed-off-by: yihong0618 <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>
1 parent 4359706 commit f5c2a41

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Lib/base64.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,14 @@ def main():
604604
with open(args[0], 'rb') as f:
605605
func(f, sys.stdout.buffer)
606606
else:
607-
func(sys.stdin.buffer, sys.stdout.buffer)
607+
if sys.stdin.isatty():
608+
# gh-138775: read terminal input data all at once to detect EOF
609+
import io
610+
data = sys.stdin.buffer.read()
611+
buffer = io.BytesIO(data)
612+
else:
613+
buffer = sys.stdin.buffer
614+
func(buffer, sys.stdout.buffer)
608615

609616

610617
if __name__ == '__main__':
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Use of ``python -m`` with :mod:`base64` has been fixed to detect input from a
2+
terminal so that it properly notices EOF.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy