develooper Front page | perl.perl5.porters | Postings from March 2019

[perl #125760] RFC remove strange behaviour of sysread()/syswrite()on UTF-8 streams

From:
Karl Williamson via RT
Date:
March 29, 2019 02:36
Subject:
[perl #125760] RFC remove strange behaviour of sysread()/syswrite()on UTF-8 streams
Message ID:
rt-4.0.24-7648-1553827001-1424.125760-15-0@perl.org
On Sun, 11 Nov 2018 19:36:38 -0800, tonyc wrote:
> On Sun, Nov 11, 2018 at 05:24:51AM -0800, Thorsten Schöning via RT
> wrote:
> > Am Sun, 09 Aug 2015 23:23:05 -0700, tonyc schrieb:
> > > if ((fp_utf8 = PerlIO_isutf8(IoIFP(io))) && !IN_BYTES) {
> > > +        if (PL_op->op_type == OP_SYSREAD || PL_op->op_type ==
> > > OP_RECV) {
> > > +            Perl_ck_warner(aTHX_ packWARN(WARN_DEPRECATED),
> > > +                           "%s() is deprecated on :utf8 handles",
> > > +                           OP_DESC(PL_op));
> > > +        }
> >
> > Could someone please explain me if the following change is valid:
> >
> > > binmode($DB::OUT, ':utf-8')
> > to
> > > binmode($DB::OUT, ':encoding(UTF-8)')
> 
> No, that won't prevent the warning.
> 
> For example, with a default 5.28.0 build:
> 
> $ ./perl -Ilib -e 'open my $f, ">", "foo"; binmode $f; binmode $f,
> ":encoding(UTF8)"; syswrite($f, "foo")'
> syswrite() is deprecated on :utf8 handles. This will be a fatal error
> in Perl 5.30 at -e line 1.
> 
> In blead this throws an error instead.
> 
> >
> > > From my understanding it is not because of statements like the
> > > following:
> >
> > > +(W deprecated) The sysread(), recv(), syswrite() and send()
> > > operators
> > > +are deprecated on handles that have the C<:utf8> layer, either
> > > +explicitly, or implicitly, eg., with the C<:encoding(UTF-16LE)>
> > > layer.
> >
> > https://rt.perl.org/Public/Ticket/Attachment/1360169/728149/0001-
> > perl-125760-deprecate-sys-read-write-send-recv-on-ut.patch
> >
> > > +Note that if the filehandle has been marked as C<:utf8>,
> > > C<sysread> will
> > > +throw an exception. The C<:encoding(...)> layer implicitly
> > > introduces the C<:utf8> layer.</sysread>
> >
> > https://rt.perl.org/Public/Ticket/Attachment/1583747/827814/0001-
> > perl-133170-fatalize-sysread-syswrite-recv-send-on-u.patch
> >
> > But the change seems to fix the warnings. Shouldn't that change still
> > result in the ":utf8"-flag being applied and therefore being still
> > wrong? The other attached patches of this bug e.g. regarding tests
> > use ":raw" only, like I understand this bug as well.
> 
> I'm not sure what you're saying here, if you could provide simple but
> complete code that doesn't behave how you expect, the result you
> expect and the result you got, we can decide if we have a code bug or
> perhaps a documentation bug.
> 
> Tony

Is this ticket closable?
-- 
Karl Williamson

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=125760



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About