Patches item #1011890, was opened at 2004-08-19 03:11 Message generated for change (Comment added) made by jlgijsbers You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011890&group_id=5470
Category: Library (Lib) Group: Python 2.4 >Status: Closed >Resolution: Accepted Priority: 5 Submitted By: Simon Percivall (percivall) Assigned to: Johannes Gijsbers (jlgijsbers) Summary: fix inspect.getsource breaking with line-continuation & more Initial Comment: The patch makes changes to inspect.py in two places: * the pattern to match against functions at line 436 is modified: lambdas should be matched even if not preceded by whitespace, as long as "lambda" isn't part of another word. * the BlockFinder class is heavily modified. Changes are: - checking for "def", "class" or "lambda" names before setting self.started to True. Then checking the same line for word characters after the colon (if the colon is on that line). If so, and the line does not end with a line continuation marker, raise EndOfBlock immediately. - adding self.passline to show that the line is to be included and no more checking is necessary on that line. Since a NEWLINE token is not generated when a line continuation marker exists, this allows getsource to continue with these functions even if the following line would not be indented. The patch might be making a mess of the simple code, and code such as code it now handles will probably not be seen often. Still, it fixes the first bug shown in "www.python.org/sf/769569". ---------------------------------------------------------------------- >Comment By: Johannes Gijsbers (jlgijsbers) Date: 2004-12-12 17:47 Message: Logged In: YES user_id=469548 Well, it took a bit longer to get test_inspect ported to unittest, but it's done now. I've also checked this in. Thanks for the patch! ---------------------------------------------------------------------- Comment By: Johannes Gijsbers (jlgijsbers) Date: 2004-08-19 19:21 Message: Logged In: YES user_id=469548 Looks very good. I've made some small changes: - Moved the __main__ section into a test_main() block for running by regrtest.py - Used the run_unittest function from test_support.py - De-abbreviated some of the test methods - Used comments instead of docstrings: unittest prints the docstring of a test method instead of the name of the test method when failing, making the failing method harder to find. Apart from that, it looks like checkin-quality to me. Still, it's kind of ugly to have a two separate files and two separate methods for testing the same module, so I guess that means I'll be converting test_inspect to unittest. I'll try to work on that tonight and post it to http://python.org/sf/736962 tomorrow. I'll merge these tests into the new test_inspect after it's checked in. ---------------------------------------------------------------------- Comment By: Simon Percivall (percivall) Date: 2004-08-19 03:25 Message: Logged In: YES user_id=329382 BTW: inspect.py CVS HEAD passes three of the tests: test_oll, test_tlli and test_onelinefunc. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011890&group_id=5470 _______________________________________________ Patches mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/patches
