[Python-checkins] bpo-17110: doc: add note how to get bytes from sys.argv (GH-12602)
Miss Islington (bot)
webhook-mailer at python.org
Sat Mar 30 01:38:17 EDT 2019
https://github.com/python/cpython/commit/5b80cb5584a72044424f2d82d0ae79c720f24c47
commit: 5b80cb5584a72044424f2d82d0ae79c720f24c47
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-03-29T22:38:14-07:00
summary:
bpo-17110: doc: add note how to get bytes from sys.argv (GH-12602)
(cherry picked from commit 38f4e468d4b55551e135c67337c18ae142193ba8)
Co-authored-by: Inada Naoki <songofacandy at gmail.com>
files:
M Doc/library/sys.rst
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index ace0e2808b18..c2c653e00beb 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -30,6 +30,12 @@ always available.
To loop over the standard input, or the list of files given on the
command line, see the :mod:`fileinput` module.
+ .. note::
+ On Unix, command line arguments are passed by bytes from OS. Python decodes
+ them with filesystem encoding and "surrogateescape" error handler.
+ When you need original bytes, you can get it by
+ ``[os.fsencode(arg) for arg in sys.argv]``.
+
.. data:: base_exec_prefix
More information about the Python-checkins
mailing list