On May 23, 2008, at 7:38 PM, Jorge Mota wrote:
> Right now the only way to avoid this error is assign err to a local
> variable
> before and use "decode"
>
> class DBQueryException(DatabaseException):
> def __init__(self, err, sql):
> self.sql = sql.lower()
> errMsg= str(err)
> self.err_desc =errMsg.decode('utf-8','ignore')
> def __str__(self):
> return self.err_desc + '\nSQL: ' + self.sql
I wrote a small script:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from dabo.dException import DBQueryException
x= DBQueryException("Error Message: øüé", "select foo from bar")
print x
...and it runs without a problem. It simulates what would happen when
the framework receives a database error containing non-ASCII
characters; in this case, using a default UTF-8 encoding.
I'm concerned about your use of str(err) above. If 'err' is a unicode
value, casting it to a string without an encoding specified can cause
lots of those painful unicode bugs.
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]