mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
include at least one example of an exception passing through pyexpat
This commit is contained in:
parent
2e56c8a260
commit
d7ea55b1b8
1 changed files with 15 additions and 0 deletions
|
|
@ -311,3 +311,18 @@ parser.Parse("<a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> ", 1)
|
||||||
handler.check(["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3",
|
handler.check(["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3",
|
||||||
"<!--abc-->", "4", "<!--def-->", "5", "</a>"],
|
"<!--abc-->", "4", "<!--def-->", "5", "</a>"],
|
||||||
"buffered text not properly split")
|
"buffered text not properly split")
|
||||||
|
|
||||||
|
# Test handling of exception from callback:
|
||||||
|
def StartElementHandler(name, attrs):
|
||||||
|
raise RuntimeError(name)
|
||||||
|
|
||||||
|
parser = expat.ParserCreate()
|
||||||
|
parser.StartElementHandler = StartElementHandler
|
||||||
|
|
||||||
|
try:
|
||||||
|
parser.Parse("<a><b><c/></b></a>", 1)
|
||||||
|
except RuntimeError, e:
|
||||||
|
if e.args[0] != "a":
|
||||||
|
print "Expected RuntimeError for element 'a'; found %r" % e.args[0]
|
||||||
|
else:
|
||||||
|
print "Expected RuntimeError for 'a'"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue