[XML-SIG] Problem with 'Bad Request'
Martin v. Loewis
martin@mira.cs.tu-berlin.de
Wed, 17 Jan 2001 01:00:43 +0100
> this is not a specific xml-Problem, but I hope you will help me
> though. I've got a problem with catching errors. More specific, I
> would like to catch 'Bad Request', which wont't work because of the
> space. Is it a bug in Python? Does anybody know a neat trick?
It is not a bug in Python; please look at the description of the
intern builtin to see why that happens (perhaps the raise/try
specification also requiring on using identical, not equal strings).
Anyway, the neat trick is to write
problemWithBlank = "Problem with blank"
def raiseProblemWithBlank():
raise problemWithBlank
def test4():
try:
raiseProblemWithBlank()
except problemWithBlank:
print "Test4: No Problem with blank" # does not work :-(
test4()
Please note that string exceptions are deprecated; the Pythonic way to
write this code is
class ProblemWithBlank(Exception):
pass
def raiseProblemWithBlank():
raise ProblemWithBlank
def test4():
try:
raiseProblemWithBlank()
except ProblemWithBlank:
print "Test4: No Problem with blank" # does not work :-(
test4()
Regards,
Martin