Re: [pysqlite] test.test() error on osX using python2.5.4
Gerhard Häring <[email protected]> Fri, 24 Jul 2009 16:44:44 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Jan Neumann wrote:
> Hello Gerhard
>
> Thanks for your swift reply!
>
> Yes, in my sitecustomize.py there is the line
>
> sys.setdefaultencoding("utf-8")
>
>
> But, if I change this to
>
> sys.setdefaultencoding("ascii")
>
> , the error is non the less raised. And in my site.py encoding is set
> to "ascii" by default.
My recommendation is to not touch this at all. Though "ascii" should
probably be the same as just leaving the file empty.
>
> If i use
>
> import sys
> sys.setdefaultencoding("ascii")
>
> in the python console, I get
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'setdefaultencoding'
Yes, you can only do that in sitecustomize.py. The function removed
during Python initialization, so it isn't available later on.
> How could I change this? Or does pysqlite work with utf-8, too?
If will affect wether the test passes or not ;-)
Again, I'd recommend you don't touch this.
You might get slightly less decoding errors when you were sloppy in your
Python code. But, and this is a big one: your code won't run anywhere
else where this hack is not present.
That's why I strongly advise against changing default encodings.
-- Gerhard