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


Groups > comp.lang.python > #63917

python-list@python.org

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'encoding': 0.05; 'directive.': 0.09; 'python': 0.11; 'codec': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'ordinal': 0.16; 'received:192.168.1.4': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'producing': 0.19; 'example': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'skip:l 30': 0.24; 'subject:python.org': 0.24; 'fine': 0.24; 'environment': 0.24; 'script': 0.25; 'skip:" 40': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; '(like': 0.30; 'subject:list': 0.30; "i'm": 0.30; 'file': 0.32; 'me?': 0.32; 'stuff': 0.32; 'run': 0.32; "can't": 0.35; 'but': 0.35; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'called': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'header:Reply-To:1': 0.67; '26,': 0.68; 'reply-to:no real name:2**0': 0.71; 'florian': 0.84; 'infamous': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:@': 0.85
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=CfYxutbl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=5FYZ9MsUIQAA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=EBOSESyhAAAA:8 a=6wqFWBqmUwcA:10 a=QfGqI5YZSUiLSsE58YoA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett:2500
Date Tue, 14 Jan 2014 17:00:48 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
To python-list@python.org
Subject python-list@python.org
References <11036720.dCfMmLrdqv@horus>
In-Reply-To <11036720.dCfMmLrdqv@horus>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5466.1389718849.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389718849 news.xs4all.nl 2846 [2001:888:2000:d::a6]:57788
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63917

Show key headers only | View raw


On 2014-01-14 16:37, 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?
>
When run from maildrop it thinks that the encoding of stdin is ASCII.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

python-list@python.org MRAB <python@mrabarnett.plus.com> - 2014-01-14 17:00 +0000

csiph-web