Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

2to3 on Mac - unknown encoding: mbcs

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


skip at pobox

Nov 5, 2009, 5:50 PM

Post #1 of 2 (39 views)
Permalink
2to3 on Mac - unknown encoding: mbcs

I tried naively running 2to3 over the SpamBayes source code on my Mac
and got this traceback:

Traceback (most recent call last):
File "/Users/skip/local/lib/python3.2/lib2to3/pgen2/tokenize.py", line 281, in find_cookie
codec = lookup(encoding)
LookupError: unknown encoding: mbcs

SpamBayes does have several files which contain the "mbcs" coding
cookie:

./windows/py2exe/gen_py/addin-designer.py
./windows/py2exe/gen_py/office-9.py
./windows/py2exe/gen_py/outlook-9.py

After a little hunting I came across the docs for the codecs module,
which for "mbcs" states:

Windows only: Encode operand according to the ANSI codepage (CP_ACP)

Is there something I can use to replace the mbcs coding cookies which
will allow 2to3 to process these Windows-specific files?

Thanks,

--
Skip Montanaro - skip[at]pobox.com - http://www.smontanaro.net/
--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

Nov 5, 2009, 10:42 PM

Post #2 of 2 (32 views)
Permalink
Re: 2to3 on Mac - unknown encoding: mbcs [In reply to]

En Thu, 05 Nov 2009 22:50:57 -0300, Skip Montanaro <skip[at]pobox.com>
escribió:

> I tried naively running 2to3 over the SpamBayes source code on my Mac
> and got this traceback:
>
> Traceback (most recent call last):
> File "/Users/skip/local/lib/python3.2/lib2to3/pgen2/tokenize.py",
> line 281, in find_cookie
> codec = lookup(encoding)
> LookupError: unknown encoding: mbcs
>
> SpamBayes does have several files which contain the "mbcs" coding
> cookie:
>
> ./windows/py2exe/gen_py/addin-designer.py
> ./windows/py2exe/gen_py/office-9.py
> ./windows/py2exe/gen_py/outlook-9.py
>
> After a little hunting I came across the docs for the codecs module,
> which for "mbcs" states:
>
> Windows only: Encode operand according to the ANSI codepage (CP_ACP)
>
> Is there something I can use to replace the mbcs coding cookies which
> will allow 2to3 to process these Windows-specific files?

Using mbcs as the source encoding declaration is evil (and stupid too).
mbcs means "whatever encoding is currently configured in Windows", it is
not a specific encoding.
You have to guess which encoding those files are in. windows-1252 (almost
the same as latin-1) is the one used in "Western Europe", which covers an
area much broader than its name.

Good luck,

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.