forcing exceptions

Nikola Skoric nick-news at net4u.hr
Fri Mar 3 15:31:58 EST 2006


In article <7xd5h3pas7.fsf at ruckus.brouhaha.com>, Paul Rubin 
<http://phr.cx@NOSPAM.invalid> says...
> Nikola Skoric <nick-news at net4u.hr> writes:
> > Is there a way to tell the interpreter to display exceptions, even those 
> > which were captured with except?
> 
> Normally you wouldn't do that unless you were trying to debug the
> interpreter itself.  It uses caught exceptions for all sorts of things
> that you probably don't want displayed.  I think even ordinary loop
> termination may be implemented using exceptions.

Yes, thanks for your quick responses, all three. You're right, I don't 
want to debug python :-) But I figured out that I don't need captured 
exceptions, the thing is that I just didn't belive the problem was that 
obvious. In fact, problem was in the except block, not in it's try 
block. The except block had this inocent statement:

print self.sect[1].encode('utf-8')

Which results in:

Traceback (most recent call last):
  File "AIDbot2.py", line 238, in ?
    bot.checkNominations()
  File "AIDbot2.py", line 201, in checkNominations
    if sect.parseSect() == 1:
  File "AIDbot2.py", line 96, in parseSect
    print self.sect[1].encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 15: 
ordinal
 not in range(128)

Now, who can it complain about 'ascii' when I said loud and clear I want 
it to encode the string to 'utf-8'??? Damn unicode.

-- 
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams" 



More information about the Python-list mailing list