Ticket #3243: exec.diff

File exec.diff, 867 bytes (added by ghazel, 12 years ago)

exec-based answer

  • twisted/test/generator_failure_tests.py

     
    6060        It should be possible to throw the exception that a Failure
    6161        represents into a generator.
    6262        """
    63         stuff = []
    64         def generator():
     63        exec """
     64        def generator(stuff):
    6565            try:
    6666                yield
    6767            except:
    6868                stuff.append(sys.exc_info())
    6969            else:
    7070                self.fail("Yield should have yielded exception.")
    71         g = generator()
     71        """.strip()
     72       
     73        stuff = []
     74        g = generator(stuff)
    7275        f = getDivisionFailure()
    7376        g.next()
    7477        self._throwIntoGenerator(f, g)