Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63962
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'encoding': 0.05; 'ascii': 0.09; 'directive.': 0.09; 'try:': 0.09; 'python': 0.11; 'codec': 0.16; 'expert.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'januar': 0.16; 'lang': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'ordinal': 0.16; 'received:192.168.1.4': 0.16; 'tried:': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'obviously': 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; 'gives': 0.31; 'file': 0.32; 'me?': 0.32; 'skip:c 30': 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; 'does': 0.39; '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; '2014,': 0.84; '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=RtvVaz4p3UEA:10 a=dgn_4FBZwhDmJ9absykA:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Wed, 15 Jan 2014 03:49:26 +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 | Re: python-list@python.org |
| References | <11036720.dCfMmLrdqv@horus> <52D56D40.1060401@mrabarnett.plus.com> <5496632.M1CKVtg2ju@horus> |
| In-Reply-To | <5496632.M1CKVtg2ju@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.5493.1389757767.18130.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389757767 news.xs4all.nl 2940 [2001:888:2000:d::a6]:45118 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63962 |
Show key headers only | View raw
On 2014-01-15 01:25, Florian Lindner wrote:
> Am Dienstag, 14. Januar 2014, 17:00:48 schrieb MRAB:
>> 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.
>
> Well, true. But what encoding does maildrop actually gives me? It obviously does not inherit LANG or is called from the MTA that way. I also tried:
>
locale.getpreferredencoding() said "ANSI_X3.4-1968", which is ASCII
(ask Wikipedia if you want to know why it's called that!).
> inData = codecs.getreader('utf-8')(sys.stdin)
> mail = inData.read()
>
> Failed also. But I'm not exactly an encoding expert.
>
Try:
sys.stdin = codecs.getreader('utf-8')(sys.stdin.detach())
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python-list@python.org MRAB <python@mrabarnett.plus.com> - 2014-01-15 03:49 +0000
csiph-web