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
Bleadperl 8752206e27 breaks a test in MLEHMANN/Coro-5.25.tar.gz #10841
Comments
From @andkOMG, this is 27 days late. Example fail report: http://www.cpantesters.org/cpan/report/b78773ba-eddc-11df-8f7c-368b0c7e6507 Cutting & pasting from there: Can't locate object method "TIESCALAR" via package "Coro::Handle::FH" at /home/sand/.cpan/build/Coro-5.25-XSKMQd/blib/lib/Coro/Handle.pm line 65. git bisect: commit 8752206 [perl #77496] tied gets scalars and globs confused perl -V: Summary of my perl5 (revision 5 version 13 subversion 6) configuration: Characteristics of this binary (from libperl): -- |
From @cpansproutOn Sun Nov 21 12:58:44 2010, andreas.koenig.7os6VVqR@franz.ak.mind.de wrote:
See my recent message to ticket #79302. This would require 27 lines in Coro/Handle.pm to change (everything with Maybe those changes to (un)tie(d) should be reverted. What do Jesse |
The RT System itself - Status changed from 'new' to 'open' |
From schmorp@schmorp.deOn Sun, Nov 21, 2010 at 01:17:28PM -0800, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
The docs I have didn't seem to indicate what Coro::Handle does wrong, or 27 lines sounds extensive - since this is an incompatible change in perl,
The code seems to match available documentation. If the code is buggy -- |
From @cpansproutOn Sun Nov 21 18:14:49 2010, schmorp@schmorp.de wrote:
Sorry, I was not clear enough. If tie $self is changed to tie *$self and The problem is that in older perls there is no way to see whether a I’m hoping you will consider it a bug, too. See perlfunc: tied VARIABLE That’s not very clear, but it sounds to me that whatever variable is |
From @cpansproutOn Sun Nov 21 18:38:20 2010, sprout wrote:
whatever variable is *named* is what will be looked at. |
From schmorp@schmorp.deOn Sun, Nov 21, 2010 at 06:38:20PM -0800, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
Well, whether that is a bug or not doesn't really have anything to do with The important question for me would be how much code breaks, and whether Maybe I am a burned child, but it seems every major perl release breaks -- |
From @cpansproutOn Sun Nov 21 18:50:56 2010, schmorp@schmorp.de wrote:
How about I revert it and add a ‘Use of tie on a handle without * is |
From @cpansproutOn Sun Nov 21 22:25:19 2010, sprout wrote:
How about this patch (plus a perldiag entry)? These three commits will Since this is a run-time check, I could not make it warn once per op. So |
From @cpansproutInline Patchdiff --git a/gv.h b/gv.h
index c61f2e6..be371f1 100644
--- a/gv.h
+++ b/gv.h
@@ -138,6 +138,9 @@ Return the SV from the GV.
#define GVf_IMPORTED_HV 0x40
#define GVf_IMPORTED_CV 0x80
+/* Temporary flag for the tie deprecation warnings. */
+#define GVf_TIEWARNED 0x100
+
#define GvINTRO(gv) (GvFLAGS(gv) & GVf_INTRO)
#define GvINTRO_on(gv) (GvFLAGS(gv) |= GVf_INTRO)
#define GvINTRO_off(gv) (GvFLAGS(gv) &= ~GVf_INTRO)
diff --git a/pp_sys.c b/pp_sys.c
index e068ec6..d27bde6 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -827,6 +827,10 @@ PP(pp_tie)
case SVt_PVGV:
case SVt_PVLV:
if (isGV_with_GP(varsv)) {
+ if (SvFAKE(varsv) && !(GvFLAGS(varsv) & GVf_TIEWARNED)) {
+ deprecate("tie on a handle without *");
+ GvFLAGS(varsv) |= GVf_TIEWARNED;
+ }
methname = "TIEHANDLE";
how = PERL_MAGIC_tiedscalar;
/* For tied filehandles, we apply tiedscalar magic to the IO
@@ -903,8 +907,14 @@ PP(pp_untie)
const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
- if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
+ if (isGV_with_GP(sv)) {
+ if (SvFAKE(sv) && !(GvFLAGS(sv) & GVf_TIEWARNED)) {
+ deprecate("untie on a handle without *");
+ GvFLAGS(sv) |= GVf_TIEWARNED;
+ }
+ if (!(sv = MUTABLE_SV(GvIOp(sv))))
RETPUSHYES;
+ }
if ((mg = SvTIED_mg(sv, how))) {
SV * const obj = SvRV(SvTIED_obj(sv, mg));
@@ -941,8 +951,14 @@ PP(pp_tied)
const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
- if (isGV_with_GP(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
+ if (isGV_with_GP(sv)) {
+ if (SvFAKE(sv) && !(GvFLAGS(sv) & GVf_TIEWARNED)) {
+ deprecate("tied on a handle without *");
+ GvFLAGS(sv) |= GVf_TIEWARNED;
+ }
+ if (!(sv = MUTABLE_SV(GvIOp(sv))))
RETPUSHUNDEF;
+ }
if ((mg = SvTIED_mg(sv, how))) {
SV *osv = SvTIED_obj(sv, mg);
diff --git a/t/op/gmagic.t b/t/op/gmagic.t
index bc8a926..850f50d 100644
--- a/t/op/gmagic.t
+++ b/t/op/gmagic.t
@@ -10,10 +10,11 @@ print "1..24\n";
my $t = 1;
tie my $c => 'Tie::Monitor';
+my $tied_to;
sub ok {
my($ok, $got, $exp, $rexp, $wexp) = @_;
- my($rgot, $wgot) = (tied $c)->init(0);
+ my($rgot, $wgot) = ($tied_to || tied $c)->init(0);
print $ok ? "ok $t\n" : "# expected $exp, got $got\nnot ok $t\n";
++$t;
if ($rexp == $rgot && $wexp == $wgot) {
@@ -56,9 +57,11 @@ ok_string($s, '0', 1, 1);
# Assignment should not ignore magic when the last thing assigned
# was a glob
+$tied_to = tied $c;
$c = *strat;
$s = $c;
ok_string $s, *strat, 1, 1;
+$tied_to = undef;
# A plain *foo should not call get-magic on *foo.
# This method of scalar-tying an immutable glob relies on details of the
diff --git a/t/op/gv.t b/t/op/gv.t
index 862a0cf..e9fde9d 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -825,6 +825,7 @@ pass('Can assign strings to typeglobs');
tie my $a, "thrext";
() = "$a"; # do a fetch; now $a holds a glob
eval { *$a = sub{} };
+ eval { $a = undef }; # workaround for untie($handle) bug
untie $a;
eval { $a = "bar" };
::is $a, "bar",
diff --git a/t/op/tie.t b/t/op/tie.t
index 6e52a6e..b68102e 100644
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -939,3 +939,26 @@ sub IO::File::TIEARRAY {
fileno FOO; tie @a, "FOO"
EXPECT
Can't locate object method "TIEARRAY" via package "FOO" at - line 5.
+########
+
+# Deprecation warnings for tie $handle
+
+use warnings 'deprecated';
+$SIG{__WARN__} = sub { $w = shift };
+$handle = *foo;
+eval { tie $handle, "" };
+print $w =~ /^Use of tie on a handle without \* is deprecated/
+ ? "ok tie\n" : "$w\n";
+$handle = *bar;
+tied $handle;
+print $w =~ /^Use of tied on a handle without \* is deprecated/
+ ? "ok tied\n" : "$w\n";
+$handle = *baz;
+untie $handle;
+print $w =~ /^Use of untie on a handle without \* is deprecated/
+ ? "ok untie\n" : "$w\n";
+
+EXPECT
+ok tie
+ok tied
+ok untie |
From @andk
> +print $w =~ /^Use of tie on a handle without \* is deprecated/ The problem with any such approach is that it is completely new to me In the past it was completely idiomatic perl to write foo(*STDOUT); sub foo { So this style is going to be verboten? I was wondering why only Marc Lehmann and Abe Timmerman have triggered I don't mind the change if it helps fixing otherwise unfixable bugs but Or what am I missing? -- |
From @LeontOn Mon, Nov 29, 2010 at 10:51 PM, Andreas J. Koenig
It is completely new to me that the argument to tie may be written
print isn't polymorphic the way tie is, it doesn't need any extra
I have used it one or two modules, but I have always used the sigiled
Where are the docs that say it is allowed to omit them? When I see Leon |
From @TuxOn Mon, 29 Nov 2010 23:47:22 +0100, Leon Timmermans <fawaka@gmail.com>
http://search.cpan.org/dist/Text-OutputFilter/ is of my hand, ant ties
-- |
From @demerphqOn 29 November 2010 23:47, Leon Timmermans <fawaka@gmail.com> wrote:
I agree. And perltie clearly shows a * sigil on the tie example for filehandles. http://perldoc.perl.org/perltie.html#Tying-FileHandles <quote> 1. tie(*FOO,'Shout'); yves -- |
From @andk
> On Mon, Nov 29, 2010 at 10:51 PM, Andreas J. Koenig
> It is completely new to me that the argument to tie may be written Good to hear different experiences.
> print isn't polymorphic the way tie is, it doesn't need any extra While I understand the argument I find this isn't documented.
> I have used it one or two modules, but I have always used the sigiled Please, just read the ticket. The modules that use it without the star MLEHMANN/Coro-5.25.tar.gz Not three especially unexperienced people.
> Where are the docs that say it is allowed to omit them? The word VARIABLE in documentations does not specify which sigil has to > When I see Fine with me but I still think the documentation ought to make this -- |
From @demerphqOn 30 November 2010 07:08, Andreas J. Koenig
No. But ones with a very long history. Maybe this is a hold over of
I am not convinced this is a sound argument. Where _else_ do we
As I said elsewhere perltie doesnt show any use of tieing a filehandle Sure it should be *better* documented, but I think one *can* argue cheers, -- |
From @ikegamiOn Tue, Nov 30, 2010 at 4:22 AM, demerphq <demerphq@gmail.com> wrote:
Maybe, but not very convincingly. It's not like you can change tie(*FH, ...) to my $fh = FH; # XXX strict error. someone could naturally assume one has to do one the following, since it's my $fh = *FH; my $fh = \*FH; And given that the first currently works... I'm not saying it shouldn't be changed. I'm saying it's a stretch to say - Eric |
From @demerphqOn 30 November 2010 20:49, Eric Brine <ikegami@adaelis.com> wrote:
Umm... I dont know about that. That would tie the variable $fh to some If it works, its an accident. This is a container/value problem. Tie acts on a container. Not on a
Again no, this is wrong. for the same reasons i stated above. (And it
Well, in perltie the only tied filehandle is written as tie *HANDLE, ... That is, WITH the * sigil. So, while you might be right in saying that tie(*$fh, ...) is not Certainly it is better documented than tie FH, ....; Of which i can find no example at all. cheers, -- |
From @LeontOn Tue, Nov 30, 2010 at 8:49 PM, Eric Brine <ikegami@adaelis.com> wrote:
It's ordinary syntax for a dereference of a globref. That's perfectly Leon |
From @cpansproutOn Sun Nov 28 12:15:12 2010, sprout wrote:
Now done as: |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#79528 (status was 'resolved')
Searchable as RT79528$
The text was updated successfully, but these errors were encountered: