Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3256
| X-Received | by 2002:a05:620a:b16:: with SMTP id t22mr11118087qkg.235.1572164178740; Sun, 27 Oct 2019 01:16:18 -0700 (PDT) |
|---|---|
| X-Received | by 2002:a25:c441:: with SMTP id u62mr3522473ybf.117.1572164178516; Sun, 27 Oct 2019 01:16:18 -0700 (PDT) |
| Path | csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!j16no4579102qtl.0!news-out.google.com!d16ni78qtp.0!nntp.google.com!j16no4579088qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | fr.comp.lang.python |
| Date | Sun, 27 Oct 2019 01:16:18 -0700 (PDT) |
| In-Reply-To | <2555f574-1849-4e12-b7b8-c61bc47ce344@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=81.49.81.242; posting-account=dcD-vwoAAAADRTmn7k3Lt-A6Fc1w3JmV |
| NNTP-Posting-Host | 81.49.81.242 |
| References | <713a01f1-05ac-4e7c-9153-afc6186ae7be@googlegroups.com> <qp0te8$igo$3@nemo.pasdenom.info> <4f94ad96-c050-4404-9522-f616c3e26a59@googlegroups.com> <qp3hlb$jfv$5@nemo.pasdenom.info> <c77b41a7-6b28-4bd6-8163-a443b3ab6cbd@googlegroups.com> <2555f574-1849-4e12-b7b8-c61bc47ce344@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <a402c2fb-c1ae-43ac-ac73-380b7c38653c@googlegroups.com> (permalink) |
| Subject | Re: fileinput |
| From | lacsaP Patatetom <patatetom@gmail.com> |
| Injection-Date | Sun, 27 Oct 2019 08:16:18 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| Lines | 55 |
| Xref | csiph.com fr.comp.lang.python:3256 |
Show key headers only | View raw
Le dimanche 27 octobre 2019 09:08:22 UTC+1, lacsaP Patatetom a écrit :
> Le dimanche 27 octobre 2019 09:04:41 UTC+1, lacsaP Patatetom a écrit :
> > Le dimanche 27 octobre 2019 08:40:28 UTC+1, Jo Engo a écrit :
> > > Le Sat, 26 Oct 2019 08:15:34 -0700, lacsaP Patatetom a écrit :
> > >
> > > > celui-ci fonctionne lorsque le fichier journal est passé en paramètre,
> > > > mais pas lorsqu'il passé sur l'entrée standard...
> > >
> > >
> > > Oui j'ai vu, mes excuse donc. Au risque de répondre encore à côté de la
> > > plaque, 1 question et 1 suggestion qui n'a rien à voir avec la question
> > >
> > > Question : où dans le fichier se situe le byte erroné ? (au milieu ou à
> > > la fin ?) si c'est à la fin ça peut expliquer la différence de taritement
> > >
> > > Suggestion
> > >
> > > Comme tu semble attendre de tels problèmes pourquoi ne traites-tu pas le
> > > fichier en raw (en 8 bits, sans tenir compte d'*aucun* caractères utf8)
> > >
> > > --
> > > Le trop de promptitude à l'erreur nous expose.
> > > -+- Pierre Corneille -+-
> >
> > il semblerait que le problème soit connu : https://bugs.python.org/issue26756
> > si sys.stdin est utilisé par fileinput alors le hook n'est pas appliqué, ce qui explique la différence de comportement...
>
> le script ci-dessous fonctionne dans tous les cas :
>
> import io
> import fileinput
> import sys
> try:
> source = sys.argv[1:]
> except IndexError:
> source = None
> sys.stdin = io.TextIOWrapper(sys.stdin.buffer, errors='ignore')
> for line in fileinput.input(source, openhook=fileinput.hook_encoded('utf-8', 'ignore')):
> print(line.strip())
la variable d'environnement PYTHONIOENCODING positionnée à UTF8:ignore (PYTHONIOENCODING=UTF8:ignore) permet aussi de contourner l'erreur liée à l'utilisation de sys.stdin
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Find similar
fileinput lacsaP Patatetom <patatetom@gmail.com> - 2019-10-25 13:04 -0700
Re: fileinput Jo Engo <yl@icite.fr> - 2019-10-26 07:43 +0000
Re: fileinput lacsaP Patatetom <patatetom@gmail.com> - 2019-10-26 08:15 -0700
Re: fileinput Jo Engo <yl@icite.fr> - 2019-10-27 07:40 +0000
Re: fileinput lacsaP Patatetom <patatetom@gmail.com> - 2019-10-27 01:04 -0700
Re: fileinput lacsaP Patatetom <patatetom@gmail.com> - 2019-10-27 01:08 -0700
Re: fileinput lacsaP Patatetom <patatetom@gmail.com> - 2019-10-27 01:16 -0700
csiph-web