diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py index 7f6a1b4a2c7..7f615958dab 100644 --- a/Lib/compiler/transformer.py +++ b/Lib/compiler/transformer.py @@ -222,6 +222,11 @@ def classdef(self, nodelist): # code for class code = self.com_node(nodelist[-1]) + if doc is not None: + assert isinstance(code, Stmt) + assert isinstance(code.nodes[0], Discard) + del code.nodes[0] + n = Class(name, bases, doc, code) n.lineno = nodelist[1][2] return n diff --git a/Tools/compiler/compiler/transformer.py b/Tools/compiler/compiler/transformer.py index 7f6a1b4a2c7..7f615958dab 100644 --- a/Tools/compiler/compiler/transformer.py +++ b/Tools/compiler/compiler/transformer.py @@ -222,6 +222,11 @@ def classdef(self, nodelist): # code for class code = self.com_node(nodelist[-1]) + if doc is not None: + assert isinstance(code, Stmt) + assert isinstance(code.nodes[0], Discard) + del code.nodes[0] + n = Class(name, bases, doc, code) n.lineno = nodelist[1][2] return n