# Buggy code
def _open_subprocess(self):
    # Force bufsize=0 on all Python versions to avoid writing the
    # unflushed buffer when closing a broken input pipe
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)

    log.debug("Opening subprocess: {0}".format(maybe_decode(fargs)))
    self.player = subprocess.Popen(
        args, stdin=self.stdin, bufsize=0, stdout=self.stdout, stderr=self.stderr
    )
    # Wait 0.5 seconds to see if program exited prematurely
    if not self.running:
        raise OSError("Process exited prematurely")

    if self.namedpipe:
        self.namedpipe.open("wb")
    elif self.http:
        self.http.open()


# Traceback (UnicodeDecodeError)
OS: macOS 10.14.2
Python: 2.7.14
Streamlink: 1.1.1
Requests(2.21.0), Socks(1.6.7), Websocket(0.47.0)
Found matching plugin twitch for URL twitch.tv/quickybaby
Plugin specific arguments:
--twitch-oauth-token=******** (oauth_token)
--twitch-disable-hosting=True (disable_hosting)
--twitch-disable-ads=True (disable_ads)
Getting live HLS streams for quickybaby
Attempting to authenticate using OAuth token
Successfully logged in as DELETE
[utils.l10n][debug] Language code: en_US
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Opening stream: 1080p60 (hls)
Starting player: /Applications/mpv.app/Contents/MacOS/mpv
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==1.1.1', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 1033, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 594, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 437, in handle_stream
success = output_stream_passthrough(plugin, stream)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 262, in output_stream_passthrough
output.open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 24, in open
self._open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 219, in _open
self._open_call()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 234, in _open_call
log.debug(u"Calling: {0}".format(fargs))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 141: ordinal not in range(128)

# Fixed code
def _open_subprocess(self):
    # Force bufsize=0 on all Python versions to avoid writing the
    # unflushed buffer when closing a broken input pipe
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)
    log.debug("Opening subprocess: {0}".format(fargs))

    self.player = subprocess.Popen(
        maybe_encode(args, get_filesystem_encoding()),
        stdin=self.stdin,
        bufsize=0,
        stdout=self.stdout,
        stderr=self.stderr,
    )
    # Wait 0.5 seconds to see if program exited prematurely
    if not self.running:
        raise OSError("Process exited prematurely")

    if self.namedpipe:
        self.namedpipe.open("wb")
    elif self.http:
        self.http.open()