New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] Tie::StdHandle::BINMODE does not handle LAYER argument #16262
Comments
From @haukexDear Perl 5 Porters, The final test in the attached script always fails (tested on Linux, sub BINMODE { binmode($_[0]) } meaning that the layer argument is not passed through. The attached sub BINMODE { &CORE::binmode(shift, @_) } This is based on the first of the patches that I wrote about a while ago Thanks, Best Regards, |
From @haukex0001-Tie-StdHandle-BINMODE-handle-layer-argument.patchFrom 6d372dc31841cd31461dc3f5d86e0f80fc2ebd0a Mon Sep 17 00:00:00 2001
From: Hauke D <haukex@zero-g.net>
Date: Mon, 20 Nov 2017 15:31:57 +0100
Subject: [PATCH] Tie::StdHandle::BINMODE: handle layer argument
BINMODE was not handling the LAYER argument.
Also bump the version number.
---
lib/Tie/Handle/stdhandle.t | 13 ++++++++++++-
lib/Tie/StdHandle.pm | 4 ++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/Tie/Handle/stdhandle.t b/lib/Tie/Handle/stdhandle.t
index d2f04bcc5c..6c20d90f2b 100644
--- a/lib/Tie/Handle/stdhandle.t
+++ b/lib/Tie/Handle/stdhandle.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-use Test::More tests => 27;
+use Test::More tests => 29;
use_ok('Tie::StdHandle');
@@ -72,6 +72,17 @@ is($b, "rhubarbX\n", "b eq rhubarbX");
$b = <$f>;
is($b, "89\n", "b eq 89");
+# binmode should pass through layer argument
+
+binmode $f, ':raw';
+ok !grep( $_ eq 'utf8', PerlIO::get_layers(tied(*$f)) ),
+ 'no utf8 in layers after binmode :raw';
+binmode $f, ':utf8';
+ok grep( $_ eq 'utf8', PerlIO::get_layers(tied(*$f)) ),
+ 'utf8 is in layers after binmode :utf8';
+
+# finish up
+
ok(eof($f), "eof");
ok(close($f), "close");
diff --git a/lib/Tie/StdHandle.pm b/lib/Tie/StdHandle.pm
index dfb86634f0..fb79a986c6 100644
--- a/lib/Tie/StdHandle.pm
+++ b/lib/Tie/StdHandle.pm
@@ -4,7 +4,7 @@ use strict;
use Tie::Handle;
our @ISA = 'Tie::Handle';
-our $VERSION = '4.5';
+our $VERSION = '4.6';
=head1 NAME
@@ -48,7 +48,7 @@ sub TELL { tell($_[0]) }
sub FILENO { fileno($_[0]) }
sub SEEK { seek($_[0],$_[1],$_[2]) }
sub CLOSE { close($_[0]) }
-sub BINMODE { binmode($_[0]) }
+sub BINMODE { &CORE::binmode(shift, @_) }
sub OPEN
{
--
2.15.0
|
From @atoomicThanks for the patch, I've kicked a smoker run with it nicolas On Mon, 20 Nov 2017 07:31:23 -0800, haukex@zero-g.net wrote:
|
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Mon, 20 Nov 2017 15:58:42 GMT, atoomic@cpan.org wrote:
Also available in this branch: smoke-me/jkeenan/haukex/132475-binmode |
From @haukexHi, Bump! Thanks for the smokers, how are things looking there? Best, On Mon, 20 Nov 2017 14:43:13 -0800, jkeenan wrote:
|
Can we merge, then? |
Fixes Perl#16262 BINMODE was not handling the LAYER argument. Also bump the version number. (cherry picked from commit 479d04b98e5b747e5c9ead7368d3e132f524a2b7) Signed-off-by: Nicolas R <atoomic@cpan.org>
Fixes #16262 BINMODE was not handling the LAYER argument. Also bump the version number. (cherry picked from commit 479d04b98e5b747e5c9ead7368d3e132f524a2b7) Signed-off-by: Nicolas R <atoomic@cpan.org>
Thanks all! |
Migrated from rt.perl.org#132475 (status was 'open')
Searchable as RT132475$
The text was updated successfully, but these errors were encountered: