Martin, Giovanni, thank you very much for your patience. I have set up a
clean Virtual Machine with a new interpreter and now I get the same
error in the standard interpreter, too. I have diffed the site.py files,
but they are unchanged to the new installation.
I have also solved my original problem (which I was trying yo reduce
with the code given): Reading a Cp1252 encoded file via
open("file").read(). It was working with my installation, packaged with
pyinstaller it failed. I am now using
codecs.open("file",encoding="Cp1252"), which I hope is the correct way
and if I compile on the VM it works on the host too.
Cheers
Sebastian
On 08/08/2011 07:57 PM, Giovanni Bajo wrote:
On Mon, 2011-08-08 at 09:05 -0700, SElsner wrote:
Hello,
Please see this short script:
# -*- coding: utf-8 -*-
a = "ä"
print unicode(a)
It does work if not compile with pyinstaller. If compiled with:
pyinstaller.py scriptname.py
I get an error:
Traceback (most recent call last):
File "<string>", line 4, in<module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
0: ordinal not in range(128)
Using latest trunk with python 2.6.6 32bit on windows xp pro 64bit
Your code above does not run in a standard Python installation:
$ cat foooo.py
# -*- coding: utf-8 -*-
a = "ä"
print unicode(a)
$ python foooo.py
Traceback (most recent call last):
File "foooo.py", line 3, in<module>
print unicode(a)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal
not in range(128)
My crystal ball says that it works for you because you have modified the
default Python encoding, maybe following an ill-advised blog post like
this:
http://blog.ianbicking.org/illusive-setdefaultencoding.html
Maybe you've put something in your site.py/sitecustomize.py. You
shouldn't do that, specifically because your code then becomes
not-interoperable with different Python installation (and thus with
PyInstaller).
The correct way to achieve what you want is to explicitly name the
encoding of your 8-bit strings during the decoding process, so either:
print unicode(a, "utf-8")
or
print a.decode("utf-8")
--
Sebastian Elsner - Pipeline TD - r i s e | fx
t: +49 30 201 803 00 [email protected]
c: +49 175 336 5739 7548 www.risefx.com
r i s e | fx GmbH
Schlesische Strasse 28, Aufgang B 10997 Berlin
Richard-Byrd-Strasse 12, 50829 Cologne
Geschaeftsfuehrer: Sven Pannicke, Robert Pinnow
Handelsregister Berlin HRB 106667 B
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyinstaller?hl=en.