def check_stack_size(self, snippet, async_=False):

    def compile_snippet(i):
        ns = {}
        script = ('def func():\n' + (i * snippet))
        if async_:
            script = ('async ' + script)
        code = compile(script, '<script>', 'exec')
        exec(code, ns, ns)
        return ns['func'].__code__
    sizes = [compile_snippet(i).co_stacksize for i in range(2, 5)]
    if (len(set(sizes)) != 1):
        import dis, io
        out = io.StringIO()
        dis.dis(compile_snippet(1), file=out)
        self.fail(('stack sizes diverge with # of consecutive snippets: %s\n%s\n%s' % (sizes, snippet, out.getvalue())))
def check_stack_size(self, snippet, async_=False):

    def compile_snippet(i):
        ns = {}
        script = ('def func():\n' + (i * snippet))
        if async_:
            script = ('async ' + script)
        code = compile(script, '<script>', 'exec')
        exec(code, ns, ns)
        return ns['func'].__code__
    sizes = [compile_snippet(i).co_stacksize for i in range(2, 5)]
    if (len(set(sizes)) != 1):
        import dis, io
        out = io.StringIO()
        dis.dis(compile_snippet(1), file=out)
        self.fail(('stack sizes diverge with # of consecutive snippets: %s\n%s\n%s' % (sizes, snippet, out.getvalue())))