Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'filename': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tries': 0.15; 'codec': 0.16; 'encode': 0.16; 'reedy': 0.16; 'wrote:': 0.18; '>>>': 0.18; '3.2': 0.18; 'convert': 0.19; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'appear': 0.23; 'replacing': 0.23; 'command': 0.24; 'fine': 0.24; 'windows': 0.26; 'invalid': 0.28; 'compile': 0.29; 'idle': 0.29; 'unicode': 0.29; 'error': 0.29; 'pm,': 0.29; "can't": 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'character': 0.34; 'running': 0.35; 'however,': 0.36; 'file': 0.36; 'explain': 0.36; 'but': 0.37; 'using': 0.38; 'received:org': 0.38; 'getting': 0.38; 'characters': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; '8bit%:21': 0.62; '11:24': 0.84; 'pasting': 0.84; 'chinese': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: UnicodeEncodeError in compile Date: Tue, 10 Jan 2012 03:08:40 -0500 References: <9043309.329.1326169476466.JavaMail.geo-discussion-forums@yqhi24> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <9043309.329.1326169476466.JavaMail.geo-discussion-forums@yqhi24> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326182952 news.xs4all.nl 6933 [2001:888:2000:d::a6]:59535 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18740 On 1/9/2012 11:24 PM, pyscripter@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 '= mbcs' in Windows, but I thought that this is not used when unicode file n= ames are provided. 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 = Chinese chars with '??' upon pasting, so that Python never gets them --=20 whereas they appear just fine in IDLE. --=20 Terry Jan Reedy