• Johannes Gijsbers's avatar
    Patch #1011890: fix inspect.getsource breaking with line-continuation & · 1542f34c
    Johannes Gijsbers yazdı
    more. Thanks to Simon Percivall!
    
    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.
    
    Also add a bunch of
    'quite-unlikely-to-occur-in-real-life-but-working-anyway' tests.
    1542f34c
Adı
Son kayıt (commit)
Son güncelleme
Demo Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Python Loading commit data...
RISCOS Loading commit data...
Tools Loading commit data...
.cvsignore Loading commit data...
.hgtags Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
aclocal.m4 Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
install-sh Loading commit data...
pyconfig.h.in Loading commit data...
setup.py Loading commit data...