]> granicus.if.org Git - python/commitdiff
bpo-17110: doc: add note how to get bytes from sys.argv (GH-12602)
authorInada Naoki <songofacandy@gmail.com>
Sat, 30 Mar 2019 05:32:08 +0000 (14:32 +0900)
committerGitHub <noreply@github.com>
Sat, 30 Mar 2019 05:32:08 +0000 (14:32 +0900)
Doc/library/sys.rst

index 0fa5bd462294f8972b9be0b6d5506f9dccfc0e2a..52026f6a2bce38e179fe4b7761428585222134bf 100644 (file)
@@ -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