Terry J. Reedy <tjre...@udel.edu> added the comment: You misunderstood my last response. The first paragraph *dismisses* the case of temporary print (raised by Charles-Axle) as out of scope for doctests and hence this issue. The next ones addresses *your* case of code *permanently* intended to print and raise and gives a workable solution to your example.
After failing to find a simpler example that works with 3.x*, I am now thinking of the following doc fix. 1. Add 'directly' before 'supported' in Tim's first sentence: "Examples containing both expected output and an exception are not supported." 2. After the next sentence of explanation, add """Instead, try something like: >>> def test(): ... print("hello") ... raise IndexError() ... >>> try: ... test() ... raise BaseException # Fail if no IndexError ... except IndexError: ... pass hello """ * I discovered a subtle consequence of the print change: "print 1, 1/0" will print '1' on a line by itself and then a traceback. "print(1,1/0)" just prints a traceback. Something like class C(): def __str__(self): raise IndexError print(1, C(), sep='\n') is required to print a value by itself on a line and then a traceback. That is no simpler and probably less realistic than test() above. ---------- keywords: +patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3722> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com