bpo-17110: doc: add note how to get bytes from sys.argv by methane · Pull Request #12602 · python/cpython (original) (raw)
You can get sys.argv as bytes using: [os.fsencode(arg) for arg in sys.argv]
.
Using surrogateescape is wrong on Windows.
Your note says "decode" but not, you have to encode sys.argv which is a list of Unicode strings.