diff options
author | Felix Yan <felixonmars@archlinux.org> | 2015-11-13 17:38:18 +0800 |
---|---|---|
committer | Felix Yan <felixonmars@archlinux.org> | 2015-11-13 17:38:18 +0800 |
commit | ab99c4d7bfe1d83c704580037e5790bb5d2c622a (patch) | |
tree | 2a6bae44719729c797523c2ff7d42609377bc8a4 | |
parent | ed08119e604de93a738b1acb0790793a64688828 (diff) | |
download | zope-tal-ab99c4d7bfe1d83c704580037e5790bb5d2c622a.tar.gz |
Add back HTMLParseError as suggested by Marius
-rw-r--r-- | src/zope/tal/htmltalparser.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/zope/tal/htmltalparser.py b/src/zope/tal/htmltalparser.py index 46f36a5..c79bbea 100644 --- a/src/zope/tal/htmltalparser.py +++ b/src/zope/tal/htmltalparser.py @@ -20,7 +20,26 @@ try: from HTMLParser import HTMLParser, HTMLParseError except ImportError: # Python 3.x - from html.parser import HTMLParser, HTMLParseError + from html.parser import HTMLParser + try: + from html.parser import HTMLParseError + except ImportError: + # Python 3.5 removed it, but we need it as a base class + # so here's a copy taken from Python 3.4: + class HTMLParseError(Exception): + def __init__(self, msg, position=(None, None)): + assert msg + self.msg = msg + self.lineno = position[0] + self.offset = position[1] + + def __str__(self): + result = self.msg + if self.lineno is not None: + result = result + ", at line %d" % self.lineno + if self.offset is not None: + result = result + ", column %d" % (self.offset + 1) + return result from zope.tal.taldefs import (ZOPE_METAL_NS, ZOPE_TAL_NS, ZOPE_I18N_NS, METALError, TALError, I18NError) |