Ticket #4530: fix_doctest_underscore_problem.diff

File fix_doctest_underscore_problem.diff, 1.3 KB (added by marcin@…, 17 years ago)
  • _doctest.py

     
    12391239            # __patched_linecache_getlines).
    12401240            filename = '<doctest %s[%d]>' % (test.name, examplenum)
    12411241
     1242            # The exec statement with 'single' mode of compilation
     1243            # overwrites the _ builtin.  Store the original value so
     1244            # that you can restore it later.
     1245            original_underscore = __builtins__['_']
     1246
    12421247            # Run the example in the given context (globs), and record
    12431248            # any exception that gets raised.  (But don't intercept
    12441249            # keyboard interrupts.)
     
    12491254                self.debugger.set_continue() # ==== Example Finished ====
    12501255                exception = None
    12511256            except KeyboardInterrupt:
     1257                __builtins__['_'] = original_underscore
    12521258                raise
    12531259            except:
    12541260                exception = sys.exc_info()
    12551261                self.debugger.set_continue() # ==== Example Finished ====
    12561262
     1263            __builtins__['_'] = original_underscore
     1264
    12571265            got = self._fakeout.getvalue()  # the actual output
    12581266            self._fakeout.truncate(0)
    12591267            outcome = FAILURE   # guilty until proved innocent or insane
Back to Top