Ok I cannot use str.
But your script is different approach that in app
put this at dException:
class DBQueryException(DatabaseException):
def __init__(self, err, sql):
print type(err)
self.sql = sql
self.err_desc = err
def __str__(self):
return self.err_desc + '\nSQL: ' + self.sql
try it with a dabo application that fail with triggers, type return:
<class 'pymssql.DatabaseError'>
in your script return
<type 'str'>
and with your string no fail, with str() get same type of var and no fail.
Is pymssql.DatabaseError with bad encoding ?
Best regards
On 5/23/08, Ed Leafe <[EMAIL PROTECTED]> wrote:
>
> 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
>
>
>
>
>
[excessive quoting removed by server]
_______________________________________________
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]