This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author siming85
Recipients siming85
Date 2015-04-29.23:08:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430348928.98.0.0978970784211.issue24078@psf.upfronthosting.co.za>
In-reply-to
Content
according to inspect.py line 675 - this is only a best effort.

is this intended?

inspect.py @ 672
    if isclass(object):
        name = object.__name__
        pat = re.compile(r'^(\s*)class\s*' + name + r'\b')
        # make some effort to find the best matching class definition:
        # use the one with the least indentation, which is the one
        # that's most probably not inside a function definition.
        candidates = []
        for i in range(len(lines)):
            match = pat.match(lines[i])
            if match:
                # if it's at toplevel, it's already the best one
                if lines[i][0] == 'c':
                    return lines, i
                # else add whitespace to candidate list
                candidates.append((match.group(1), i))
        if candidates:
            # this will sort by whitespace, and by line number,
            # less whitespace first
            candidates.sort()
            return lines, candidates[0][1]
        else:
            raise OSError('could not find class definition')
History
Date User Action Args
2015-04-29 23:08:49siming85setrecipients: + siming85
2015-04-29 23:08:48siming85setmessageid: <1430348928.98.0.0978970784211.issue24078@psf.upfronthosting.co.za>
2015-04-29 23:08:48siming85linkissue24078 messages
2015-04-29 23:08:48siming85create