Encoding and decoding example string works as expected:: ~$ python3 -m base64 -t b'Aladdin:open sesame' b'QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n' b'Aladdin:open sesame' Encoding a file raises TypeError:: ~$ python3 -m base64 -e foo.txt Traceback (most recent call last): File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 160, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 73, in _run_code exec(code, run_globals) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 402, in main() File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 386, in main func(open(args[0], 'rb'), sys.stdout) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 319, in encode output.write(line) TypeError: must be str, not bytes Encoding from stdin also raises TypeError, although slightly differently:: ~$ cat foo.txt | python3 -m base64 Traceback (most recent call last): File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 160, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 73, in _run_code exec(code, run_globals) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 402, in main() File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 388, in main func(sys.stdin, sys.stdout) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 318, in encode line = binascii.b2a_base64(s) TypeError: must be bytes or buffer, not str Decoding a file raises TypeError:: ~$ python3 -m base64 -d foo.txt.b64 Traceback (most recent call last): File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 160, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/home/me/opt/python3.2/lib/python3.2/runpy.py", line 73, in _run_code exec(code, run_globals) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 402, in main() File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 386, in main func(open(args[0], 'rb'), sys.stdout) File "/home/me/opt/python3.2/lib/python3.2/base64.py", line 329, in decode output.write(s) TypeError: must be str, not bytes .. vim:filetype=rst