Patch #1550800: make exec a function.
diff --git a/Lib/doctest.py b/Lib/doctest.py
index bdd284a..435e13b 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1209,8 +1209,8 @@
             # keyboard interrupts.)
             try:
                 # Don't blink!  This is where the user's code gets run.
-                exec compile(example.source, filename, "single",
-                             compileflags, 1) in test.globs
+                exec(compile(example.source, filename, "single",
+                             compileflags, 1), test.globs)
                 self.debugger.set_continue() # ==== Example Finished ====
                 exception = None
             except KeyboardInterrupt: