def test_errorDuringExec(self):
        """
        When L{os.execvpe} raises an exception, it will format that exception
        on stderr as UTF-8, regardless of system encoding information.
        """

        def execvpe(*args, **kw):
            # Ensure that real traceback formatting has some non-ASCII in it,
            # by forcing the filename of the last frame to contain non-ASCII.
            filename = u"<\N{SNOWMAN}>"
            if not isinstance(filename, str):
                filename = filename.encode("utf-8")
            codeobj = compile("1/0", filename, "single")
            eval(codeobj)

        self.patch(os, "execvpe", execvpe)
        self.patch(sys, "getfilesystemencoding", lambda: "ascii")

        reactor = self.buildReactor()
        output = io.BytesIO()

        @reactor.callWhenRunning
        def whenRunning():
            class TracebackCatcher(ProcessProtocol, object):
                errReceived = output.write
                def processEnded(self, reason):
                    reactor.stop()
            reactor.spawnProcess(TracebackCatcher(), pyExe,
                                 [pyExe, b"-c", b""])

        self.runReactor(reactor, timeout=30)
        self.assertIn(u"\N{SNOWMAN}".encode("utf-8"), output.getvalue())

        When L{os.execvpe} raises an exception, it will format that exception
        on stderr as UTF-8, regardless of system encoding information.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_process.py