On Thu, Sep 11, 2008 at 10:56 AM, Edward K. Ream <[EMAIL PROTECTED]> wrote:
> The 2to3 script is still broken: > > C:\Python30\Tools\Scripts>c:\python30\python.exe 2to3.py > Traceback (most recent call last): > File "2to3.py", line 5, in <module> > sys.exit(refactor.main()) > TypeError: main() takes at least 1 positional argument (0 given) I hacked 2to3.py as follows: #!/usr/bin/env python from lib2to3 import refactor import sys import os sys.exit(refactor.main(fixer_dir=os.curdir)) This mostly seems to work. However, non-ascii characters can cause a crash: QQQQQQ C:\leo.repo\trunk\leo>fix test\fix-failure.py C:\leo.repo\trunk\leo>c:\Python30\python.exe c:\Python30\Tools\Scripts\2to3.py test\fix-failure.py Traceback (most recent call last): File "c:\Python30\Tools\Scripts\2to3.py", line 9, in <module> sys.exit(refactor.main(fixer_dir=os.curdir)) File "c:\python30\lib\lib2to3\refactor.py", line 85, in main rt.refactor_args(args) File "c:\python30\lib\lib2to3\refactor.py", line 243, in refactor_args self.refactor_file(arg) File "c:\python30\lib\lib2to3\refactor.py", line 272, in refactor_file input = f.read() + "\n" # Silence certain parse errors File "c:\python30\lib\io.py", line 1719, in read decoder.decode(self.buffer.read(), final=True)) File "c:\python30\lib\io.py", line 1294, in decode output = self.decoder.decode(input, final=final) File "c:\python30\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 47: character maps to <undefined> C:\leo.repo\trunk\leo>print /d:con test\fix-failure.py C:\leo.repo\trunk\leo\test\fix-failure.py is currently being printed # -*- coding: utf-8 -*- s = 'abc'.replace(u'ΓÇ¥ ΓÇ£', '" "') ♀ C:\leo.repo\trunk\leo> QQQQQQ The actual contents of the file are: # -*- coding: utf-8 -*- s = 'abc'.replace(u'" "', '" "') BTW, in other situations I've seen similar crashes with non-ascii characters outside the first 256 characters on Python 2.5, which seems strange to me because Leo handles all kinds of unicode characters correctly. I have no idea whether I am doing something wrong. The following appears in my sitecustomize.py file: sys.setdefaultencoding('utf-8') Edward -------------------------------------------------------------------- Edward K. Ream email: [EMAIL PROTECTED] Leo: http://webpages.charter.net/edreamleo/front.html -------------------------------------------------------------------- _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com