# Buggy code
def do_ClassDef(self, node):
    result = []
    name = node.name  # Only a plain string is valid.
    bases = [self.visit(z) for z in node.bases] if node.bases else []
    if getattr(node, "keywords", None):  # Python 3
        for keyword in node.keywords:
            bases.append("%s=%s" % (keyword.arg, self.visit(keyword.value)))
    if getattr(node, "starargs", None):  # Python 3
        bases.append("*%s", self.visit(node.starargs))
    if getattr(node, "kwargs", None):  # Python 3
        bases.append("*%s", self.visit(node.kwargs))
    if bases:
        result.append(self.indent("class %s(%s):\n" % (name, ",".join(bases))))
    else:
        result.append(self.indent("class %s:\n" % name))
    for z in node.body:
        self.level += 1
        result.append(self.visit(z))
        self.level -= 1
    return "".join(result)


# Traceback (AttributeError)
Trying to create a QVariant instance of QMetaType::Void type, an
invalid QVariant will be constructed instead

[this is repeated many many times]

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 74, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test: simple

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 22, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test: no double-underlines

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 73, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test: long underlines

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 34, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test: long overlines

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 35, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test rST import test: trailing whitespace

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 22, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test leo_rst

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 48, in <module>
assert root.h.startswith('@@'), root.h
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 1635, in __get_h
return p.headString()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoNodes.py", line 672, in headString
return self.v.headString()
AttributeError: 'NoneType' object has no attribute 'headString'

======================================================================
ERROR: runTest (leo.core.leoTest.GeneralTestCase)
@test x.makeShadowDirectory

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 31, in <module>
deleteShadowDir(shadow_dir)
File "/home/tbrown/.leo/scriptFile.py", line 20, in deleteShadowDir
os.rmdir(shadow_dir)
OSError: [Errno 39] Directory not empty: '/home/tbrown/.leo/shadow'

======================================================================
FAIL: runTest (leo.core.leoTest.GeneralTestCase)
@test all commands have an event arg

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 26, in <module>
assert arg0 in expected or arg1 in expected, message
AssertionError:
no event arg for command quickmove_bookmark_to_first_child, func: <lambda>
args: ArgSpec(args=['e'], varargs=None, keywords=None, defaults=None)

======================================================================
FAIL: runTest (leo.core.leoTest.GeneralTestCase)
@test add/delete html comments

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 27, in <module>
assert p.b == s,'fail5: s\n%s\nresult\n%s' % (repr(s),repr(p.b))
AssertionError: fail5: s
u'@language html\n<html>\n    text \n</html>\n'
result
u'@language html\n<html>\n   text \n</html>\n'

======================================================================
FAIL: runTest (leo.core.leoTest.GeneralTestCase)
@test helpForbindings

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 7, in <module>
c.helpCommands.helpForBindings()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/commands/helpCommands.py", line 326, in helpForBindings
self.c.putHelpFor(s)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoCommands.py", line 7020, in putHelpFor
g.app.gui.put_help(c, s, short_title)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/qt_gui.py", line 1029, in put_help
assert vr # For unit testing.
AssertionError

======================================================================
FAIL: runTest (leo.core.leoTest.GeneralTestCase)
@test helpForFindCommands

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 7, in <module>
c.helpCommands.helpForFindCommands()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/commands/helpCommands.py", line 756, in helpForFindCommands
self.c.putHelpFor(s)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoCommands.py", line 7020, in putHelpFor
g.app.gui.put_help(c, s, short_title)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/qt_gui.py", line 1029, in put_help
assert vr # For unit testing.
AssertionError

======================================================================
FAIL: runTest (leo.core.leoTest.GeneralTestCase)
@test helpForMinibuffer

----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 211, in runTest
builtins.execfile(scriptFile, d)
File "/home/tbrown/.leo/scriptFile.py", line 6, in <module>
c.helpCommands.helpForMinibuffer()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/commands/helpCommands.py", line 815, in helpForMinibuffer
c.putHelpFor(s)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoCommands.py", line 7020, in putHelpFor
g.app.gui.put_help(c, s, short_title)
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/plugins/qt_gui.py", line 1029, in put_help
assert vr # For unit testing.
AssertionError

======================================================================
FAIL: runTest (leo.core.leoTest.EditBodyTestCase)
EditBodyTestCase: addComments
----------------------------------------------------------------------
Traceback (most recent call last):
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 105, in runTest
self.editBody()
File "/mnt/usr1/usr1/home/tbrown/t/Package/leo/git/leo-editor/leo/core/leoTest.py", line 85, in editBody
compareHeadlines=False), '%s: before undo1' % commandName
AssertionError: addComments: before undo1

----------------------------------------------------------------------
Ran 904 tests in 108.952s

FAILED (failures=6, errors=8, skipped=28)
tb:la: ~/t/Package/leo/git/leo-editor
leo-editorlocalhost:11.0>

# Fixed code
def do_ClassDef(self, node):
    result = []
    name = node.name  # Only a plain string is valid.
    bases = [self.visit(z) for z in node.bases] if node.bases else []
    if getattr(node, "keywords", None):  # Python 3
        for keyword in node.keywords:
            bases.append("%s=%s" % (keyword.arg, self.visit(keyword.value)))
    if getattr(node, "starargs", None):  # Python 3
        bases.append("*%s" % self.visit(node.starargs))
    if getattr(node, "kwargs", None):  # Python 3
        bases.append("*%s" % self.visit(node.kwargs))
    if bases:
        result.append(self.indent("class %s(%s):\n" % (name, ",".join(bases))))
    else:
        result.append(self.indent("class %s:\n" % name))
    for z in node.body:
        self.level += 1
        result.append(self.visit(z))
        self.level -= 1
    return "".join(result)