Subject: | Hash order traversal dependency bug |
Sorry to bug you again. In 5.18 we very likely will have new logic which
will make the keyorder of hashes random. Each hash will have its own
order, and indeed the order will change every modification to the hash.
As such you need to sort the keys you return.
Attached is a patch to fix this, which I have applied to yves/hv_h_split
in perl.git.
I have marked this ticket as important as it is effectively a blocker for
5.18.
Ps: the other hash order dependency ticket I filed was reopened when I
replied to let you know that your new release was merged to blead.
Subject: | 0001-Ensure-that-Module-Pluggable-returns-plugins-in-a-pr.patch |
From 8bc0996fa45db307e4267bd6c482933eff18deec Mon Sep 17 00:00:00 2001
From: Yves Orton <demerphq@gmail.com>
Date: Tue, 19 Feb 2013 12:14:44 +0100
Subject: [PATCH] Ensure that Module::Pluggable returns plugins in a
predictable order
As of 5.18 hash traversal order will vary per-hash, and indeed more
frequently. The likelihood this results in one of the tests in M::P
failing becomes very high.
In general the test expectations were fragile, but probably almost
never failed. With hash traversal randomization they will fail
regularly.
---
cpan/Module-Pluggable/lib/Module/Pluggable.pm | 2 +-
.../lib/Module/Pluggable/Object.pm | 4 ++--
cpan/Module-Pluggable/t/19can_ok_clobber.t | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cpan/Module-Pluggable/lib/Module/Pluggable.pm b/cpan/Module-Pluggable/lib/Module/Pluggable.pm
index a723dbc..9e7962e 100644
--- a/cpan/Module-Pluggable/lib/Module/Pluggable.pm
+++ b/cpan/Module-Pluggable/lib/Module/Pluggable.pm
@@ -11,7 +11,7 @@ use if $] > 5.017, 'deprecate';
# Peter Gibbons: I wouldn't say I've been missing it, Bob!
-$VERSION = '4.6'; # core release only!
+$VERSION = '4.7';
$FORCE_SEARCH_ALL_PATHS = 0;
sub import {
diff --git a/cpan/Module-Pluggable/lib/Module/Pluggable/Object.pm b/cpan/Module-Pluggable/lib/Module/Pluggable/Object.pm
index 3c198a7..b218362 100644
--- a/cpan/Module-Pluggable/lib/Module/Pluggable/Object.pm
+++ b/cpan/Module-Pluggable/lib/Module/Pluggable/Object.pm
@@ -83,7 +83,7 @@ sub plugins {
if (defined $self->{'instantiate'}) {
my $method = $self->{'instantiate'};
my @objs = ();
- foreach my $package (keys %plugins) {
+ foreach my $package (sort keys %plugins) {
next unless $package->can($method);
my $obj = eval { $package->$method(@_) };
$self->{'on_instantiate_error'}->($package, $@) if $@;
@@ -92,7 +92,7 @@ sub plugins {
return @objs;
} else {
# no? just return the names
- return keys %plugins;
+ return sort keys %plugins;
}
}
diff --git a/cpan/Module-Pluggable/t/19can_ok_clobber.t b/cpan/Module-Pluggable/t/19can_ok_clobber.t
index 07c598b..8b1466d 100644
--- a/cpan/Module-Pluggable/t/19can_ok_clobber.t
+++ b/cpan/Module-Pluggable/t/19can_ok_clobber.t
@@ -21,7 +21,7 @@ is_deeply(
\@plugins_after,
\@plugins,
"plugins haven't been clobbered",
-);
+) or diag Dumper(\@plugins_after,\@plugins);
can_ok ($foo, 'frobnitz');
@@ -30,7 +30,7 @@ is_deeply(
\@plugins_after,
\@plugins,
"plugins haven't been clobbered",
-) or diag Dumper ;
+) or diag Dumper(\@plugins_after,\@plugins);
--
1.7.5.4