Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'encoded': 0.05; 'terry': 0.07; 'python': 0.08; 'filename': 0.09; 'reply- to:addr:comp.lang.python': 0.09; 'to:addr:comp.lang.python': 0.09; 'utf-8': 0.09; 'tries': 0.15; '8bit%:71': 0.16; 'codec': 0.16; 'encode': 0.16; 'reedy': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; '3.2': 0.18; 'convert': 0.19; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'appear': 0.23; 'replacing': 0.23; 'cc:2**0': 0.24; 'command': 0.24; 'fine': 0.24; 'compiled': 0.25; 'windows': 0.26; 'received:209.85.220': 0.27; 'invalid': 0.28; 'compile': 0.29; 'idle': 0.29; 'unicode': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'pm,': 0.29; 'pattern': 0.30; "can't": 0.32; 'header:User-Agent:1': 0.33; 'character': 0.34; 'from:addr:googlemail.com': 0.34; 'thank': 0.35; 'running': 0.35; 'however,': 0.36; 'file': 0.36; 'explain': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'getting': 0.38; 'characters': 0.39; 'why': 0.39; 'received:209': 0.40; '8bit%:21': 0.62; 'header :Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply- to:addr:googlegroups.com': 0.74; '11:24': 0.84; 'pasting': 0.84; 'trick.': 0.84; 'chinese': 0.85; 'skip:2 50': 0.91 Newsgroups: comp.lang.python Date: Tue, 10 Jan 2012 02:53:55 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=1.168.129.93; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <9043309.329.1326169476466.JavaMail.geo-discussion-forums@yqhi24> User-Agent: G2/1.0 X-Google-Web-Client: true MIME-Version: 1.0 Subject: Re: UnicodeEncodeError in compile From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: comp.lang.python@googlegroups.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326192839 news.xs4all.nl 6938 [2001:888:2000:d::a6]:39657 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18745 Terry Reedy=E6=96=BC 2012=E5=B9=B41=E6=9C=8810=E6=97=A5=E6=98=9F=E6=9C=9F= =E4=BA=8CUTC+8=E4=B8=8B=E5=8D=884=E6=99=8208=E5=88=8640=E7=A7=92=E5=AF=AB= =E9=81=93=EF=BC=9A > On 1/9/2012 11:24 PM, pyscr...@gmail.com wrote: > > Using python 3.2 in Windows 7 I am getting the following: > > > >>> compile('pass', r'c:\temp\=E5=B7=A5=E5=85=B7\module1.py', 'exec') > > UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0-= -1: invalid character > > > > Can anybody explain why the compile statement tries to convert the unic= ode filename using mbcs? I know that sys.getfilesystemencoding returns 'mb= cs' in Windows, but I thought that this is not used when unicode file names= are provided. >=20 > I get the same error running 3.2.2 under IDLE but not when pasting into= =20 > Command Prompt. However, Command Prompt may be cheating by replacing the= =20 > Chinese chars with '??' upon pasting, so that Python never gets them --= =20 > whereas they appear just fine in IDLE. >=20 > --=20 > Terry Jan Reedy Thank you about the trick.=20 Use some wildcat pattern to get the name.py compiled to pwc in some=20 directory with utf-8 encoded chars.=20