[New-bugs-announce] [issue24674] pyclbr not recursively showing classes in packages

David Worenklein report at bugs.python.org
Mon Jul 20 15:26:41 CEST 2015

New submission from David Worenklein:

In the following example, pyclbr does not report that foo.module.A is a superclass of C:

import foo.module
class C(foo.module.B):

class A(object):
    def foo(self):
        print "bar"

class B(A):

import pyclbr

def superclasses_of(class_data):
    classes = [ class_data ]
    super_classes = []
    while classes:
        class_data = classes.pop()
        if isinstance(class_data, basestring):
            super_classes.append( class_data.module+'.'+class_data.name )
            for c in class_data.super:
                classes.append( c )
    return super_classes

module = pyclbr.readmodule('module2',['.','./foo'])
for class_name, class_data in module.items():
    print "%s => %s" % (class_name, superclasses_of(class_data))

C => ['foo.module.B']

I've attached a patch to pyclbr.py to fix this.

files: pyclbr.patch
keywords: patch
messages: 246990
nosy: worenklein
priority: normal
severity: normal
status: open
title: pyclbr not recursively showing classes in packages
versions: Python 2.7
Added file: http://bugs.python.org/file39961/pyclbr.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list