Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'true,': 0.05; 'level,': 0.07; 'problem:': 0.07; 'anymore.': 0.09; 'ascii': 0.09; 'assuming': 0.09; 'directive.': 0.09; 'enjoys': 0.09; 'locale': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runs': 0.10; 'python': 0.11; 'jan': 0.12; '8-bit': 0.16; 'ascii,': 0.16; 'command-line': 0.16; 'directive': 0.16; 'encodings': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sign.': 0.16; 'stdout': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'wed,': 0.18; "hasn't": 0.19; 'producing': 0.19; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'documented': 0.24; 'subject:python.org': 0.24; 'fine': 0.24; 'helpful': 0.24; "i've": 0.25; 'script': 0.25; 'header:X -Complaints-To:1': 0.27; 'point': 0.28; 'host': 0.29; '(like': 0.30; 'subject:list': 0.30; "i'm": 0.30; 'usually': 0.31; '(although': 0.31; '+0100,': 0.31; 'apparently': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'service,': 0.32; 'linux': 0.33; 'level.': 0.33; 'third': 0.33; 'problem': 0.35; 'knows': 0.35; 'problem.': 0.35; 'but': 0.35; 'interaction': 0.36; 'largely': 0.36; 'otherwise.': 0.36; 'url:org': 0.36; 'should': 0.36; 'detail': 0.37; 'application': 0.37; 'ben': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'rather': 0.38; 'that,': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'email?': 0.60; 'greatest': 0.60; 'hope': 0.61; 'entire': 0.61; 'more': 0.64; 'default': 0.69; 'emails,': 0.69; '*and*': 0.84; '1991': 0.84; 'florian': 0.84; 'hijacking': 0.84; 'infamous': 0.84; 'subject:@': 0.85; '1970': 0.91; '\xe2\x80\x9cthe': 0.91; 'from.': 0.93; 'confidence': 0.95; 'enquiry': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: python-list@python.org Date: Thu, 16 Jan 2014 11:52:41 +1100 References: <11036720.dCfMmLrdqv@horus> <52D56D40.1060401@mrabarnett.plus.com> <52d729fd$0$29970$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:3LZHyZ+qBkfim8l4tOMKHoyLwpY= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389833576 news.xs4all.nl 2851 [2001:888:2000:d::a6]:52664 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64031 Steven D'Aprano writes: > On Wed, 15 Jan 2014 02:25:34 +0100, Florian Lindner wrote: > >> On 2014-01-14 16:37, Florian Lindner wrote: > >> > I'm using python 3.2.3 on debian wheezy. My script is called from > >> > my mail delivery agent (MDA) maildrop (like procmail) through > >> > it's xfilter directive. > >> > > >> > Script works fine when used interactively, e.g. ./script.py < > >> > testmail but when called from maildrop it's producing an infamous > >> > UnicodeDecodeError: > > What's maildrop? When using third party libraries, it's often helpful to > point to give some detail on what they are and where they are from. It's not a library; as he says, it's an MDA program. It is from the Courier mail application . >From that, I understand Florian to be saying his Python program is invoked via command-line from some configuration directive for Maildrop. > What does the maildrop documentation say about encodings and/or > malformed email? I think this is the more likely line of enquiry to diagnose the problem. > For a modern Linux system to be using the C encoding is not a good > sign. That's true, but it's likely a configuration problem: the encoding needs to be set *and* obeyed at an administrative and user-profile level. > It's not 1970 anymore. I would expect it should be using UTF-8. But I > don't think that's relevant to your problem (although a mis-configured > system may make it worse). Since the MDA runs usually not as a system service, but rather at a user-specific level, I would expect some interaction of the host locale and the user-specific locale is the problem. > Who knows? What's maildrop? What does its documentation say about > encodings? I hope the original poster enjoys manpages, since that's how the program is documented . > The fact that it is using ASCII apparently by default does not give me > confidence that it knows how to deal with 8-bit emails, but I might be > completely wrong. I've found that the problem is often that Python is the party assuming that stdin and stdout are ASCII, largely because it hasn't been told otherwise. -- \ “The greatest tragedy in mankind's entire history may be the | `\ hijacking of morality by religion.” —Arthur C. Clarke, 1991 | _o__) | Ben Finney