Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63924 > unrolled thread

Re: Encoding trouble when script called from application

Started byPeter Otten <__peter__@web.de>
First post2014-01-14 18:43 +0100
Last post2014-01-14 18:43 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Encoding trouble when script called from application Peter Otten <__peter__@web.de> - 2014-01-14 18:43 +0100

#63924 — Re: Encoding trouble when script called from application

FromPeter Otten <__peter__@web.de>
Date2014-01-14 18:43 +0100
SubjectRe: Encoding trouble when script called from application
Message-ID<mailman.5469.1389721451.18130.python-list@python.org>
Florian Lindner wrote:

> Hello!
> 
> 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:
> 
> File "/home/flindner/flofify.py", line 171, in main
>      mail = sys.stdin.read()
> File "/usr/lib/python3.2/encodings/ascii.py", line 26, in decode
>      return codecs.ascii_decode(input, self.errors)[0]
> 
> Exception for example is always like
> 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 869:
> ordinal not in range(128) UnicodeDecodeError: 'ascii' codec can't decode
> byte 0xc3 in position 1176: ordinal not in range(128) UnicodeDecodeError:
> 'ascii' codec can't decode byte 0x8c in position 846: ordinal not in
> range(128)
> 
> I read mail from stdin "mail = sys.stdin.read()"
> 
> Environment when called is:
> 
> locale.getpreferredencoding(): ANSI_X3.4-1968
> environ["LANG"]: C
> 
> System environment when using shell is:
> 
> ~ % echo $LANG
> en_US.UTF-8
> 
> As far as I know when reading from stdin I don't need an decode(...) call,
> since stdin has a decoding. I also tried some decoding/encoding stuff but
> changed nothing.
> 
> Any ideas to help me?

I known nothing about maildrop, but found

> add "import LANG" to .maildropfilter.

in this thread:

<http://courier-mail-server.10983.n7.nabble.com/Maildrop-behaviour-change-
td18610.html>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web