[wwwsearch-commits] r36201 - wwwsearch/ClientForm/trunk
jjlee at codespeak.net
jjlee at codespeak.net
Sun Jan 7 19:29:37 CET 2007
Author: jjlee
Date: Sun Jan 7 19:29:35 2007
New Revision: 36201
Modified:
wwwsearch/ClientForm/trunk/ClientForm.py
wwwsearch/ClientForm/trunk/test.py
Log:
2.0 fixes
Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py (original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py Sun Jan 7 19:29:35 2007
@@ -447,8 +447,14 @@
):
pass
else:
- class ParseError(sgmllib.SGMLParser):
- pass
+ if hasattr(sgmllib, "SGMLParseError"):
+ SGMLLIB_PARSEERROR = sgmllib.SGMLParseError
+ class ParseError(sgmllib.SGMLParseError):
+ pass
+ else:
+ SGMLLIB_PARSEERROR = RuntimeError
+ class ParseError(RuntimeError):
+ pass
class _AbstractFormParser:
@@ -858,7 +864,7 @@
def feed(self, data):
try:
sgmllib.SGMLParser.feed(self, data)
- except sgmllib.SGMLParseError, exc:
+ except SGMLLIB_PARSEERROR, exc:
raise ParseError(exc)
@@ -881,7 +887,7 @@
def feed(self, data):
try:
self.bs_base_class.feed(self, data)
- except sgmllib.SGMLParseError, exc:
+ except SGMLLIB_PARSEERROR, exc:
raise ParseError(exc)
Modified: wwwsearch/ClientForm/trunk/test.py
==============================================================================
--- wwwsearch/ClientForm/trunk/test.py (original)
+++ wwwsearch/ClientForm/trunk/test.py Sun Jan 7 19:29:35 2007
@@ -225,15 +225,19 @@
def test_failing_parse(self):
# XXX couldn't provoke an error from BeautifulSoup (!), so this has not
- # been tested with RobuststFormParser
+ # been tested with RobustFormParser
import sgmllib
- f = StringIO("<!!!!>")
- base_uri = "http://localhost/"
- self.assertRaises(
- ClientForm.ParseError,
- ClientForm.ParseFile, f, base_uri, backwards_compat=False,
- )
- self.assert_(issubclass(ClientForm.ParseError, sgmllib.SGMLParseError))
+ # Python 2.0 sgmllib raises RuntimeError rather than SGMLParseError,
+ # but seems never to even raise that except as an assertion, from
+ # reading the code...
+ if hasattr(sgmllib, "SGMLParseError"):
+ f = StringIO("<!!!!>")
+ base_uri = "http://localhost/"
+ self.assertRaises(
+ ClientForm.ParseError,
+ ClientForm.ParseFile, f, base_uri, backwards_compat=False,
+ )
+ self.assert_(issubclass(ClientForm.ParseError, sgmllib.SGMLParseError))
def test_unknown_control(self):
f = StringIO(
More information about the wwwsearch-commits
mailing list