def handle_endtag(self, tag):
        if len(self.context) > 0:
            expected = self.context.pop()
            if expected.name != tag:
                raise Exception("Invalid endtag. Expected </%s>, found <%s>" %
                                (expected.name, tag))
        else:
            raise Exception("Unexpected endtag </%s> but context is empty" %
                            tag)
        if not expected.ignored:
            self.write_endtag(tag)
dataset/ETHPy150Open lsaffre/lino/lino/utils/mytidylib.py/MyHTMLParser.handle_endtag/original