On 8/6/06, Stefan Behnel
Well, I'm not the one who put it there (and I definitely would not have used it in the first place). Thing is, lxml is heading for ElementTree compatibility and ElementTree raises a plain SyntaxError in the place where we raise LxmlSyntaxError. So removing the superclass would break compatibility to ET and also break existing code that depends on it...
Ok, I see. The SyntaxError is used directly in the ElementPath module. ;-( There's not going to be a really clean way to do this, or at least I can't think of it off-hand. Here's what I came up with; it's probably similar to what you did: =========================================== _newstyle_exceptions = isinstance(Exception, type) class Error(Exception): pass class LxmlError(Error): def __init__(self, *args): if _newstyle_exceptions: super(LxmlError, self).__init__(*args) else: Error.__init__(self, *args) self.error_log = [] class XPathError(LxmlError): pass class LxmlSyntaxError(LxmlError, SyntaxError): pass class XPathSyntaxError(LxmlSyntaxError, XPathError): pass raise XPathSyntaxError, "some message" =========================================== -Fred -- Fred L. Drake, Jr. <fdrake at gmail.com> "Every sin is the result of a collaboration." --Lucius Annaeus Seneca