Bug#834800: Info received (libkavorka-perl: depends on libdata-alias-perl, broken with Perl 5.24)

Daniel Dehennin daniel.dehennin at baby-gnu.org
Wed Dec 14 13:41:55 UTC 2016


Hello,

You can find the fix in the following pull request, the package build
fine with all test passing.

The Moops tests are fine too.

Regards.

The following changes since commit dd39524de100d63812adf7ef9f632b798dae6ecd:

  Prepare for release: Update changelog and copyright hints. (2015-05-02 11:55:01 +0200)

are available in the git repository at:

  git://git.baby-gnu.net/libkavorka-perl.git fix/remove-data-alias-dependency

for you to fetch changes up to 88347ad01e9b737627f8bc933156e3f68e333e88:

  Remove Data::Alias dependency (2016-12-14 14:35:50 +0100)

----------------------------------------------------------------
Daniel Dehennin (1):
      Remove Data::Alias dependency

 debian/control                                    |   1 -
 debian/patches/remove-data-alias-dependency.patch | 158 ++++++++++++++++++++++
 debian/patches/series                             |   1 +
 debian/rules                                      |   2 +-
 4 files changed, 160 insertions(+), 2 deletions(-)
 create mode 100644 debian/patches/remove-data-alias-dependency.patch
 create mode 100644 debian/patches/series

diff --git a/debian/control b/debian/control
index 2bdb306..3731497 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,6 @@ Build-Depends: cdbs,
  devscripts,
  debhelper,
  dh-buildinfo,
- libdata-alias-perl,
  libexporter-tiny-perl,
  libmodule-runtime-perl,
  libpadwalker-perl,
diff --git a/debian/patches/remove-data-alias-dependency.patch b/debian/patches/remove-data-alias-dependency.patch
new file mode 100644
index 0000000..b7411a3
--- /dev/null
+++ b/debian/patches/remove-data-alias-dependency.patch
@@ -0,0 +1,158 @@
+From: Daniel Dehennin <daniel.dehennin at baby-gnu.org>
+Subject: Data::Alias is broken on perl >= 5.24
+Origin: https://github.com/tobyink/p5-kavorka/pull/19
+Bug: https://github.com/tobyink/p5-kavorka/issues/18
+
+The Data::Alias module itself explains:
+
+    “...you should prefer to use the core facility rather than use
+    this module. If you are already using this module and are now
+    using a sufficiently recent Perl, you should attempt to migrate to
+    the core facility...”
+
+The idea is to use core refaliasing when available and Data::Alias
+otherwise.
+
+This patch is a merge of the 2 commits of the pull request.
+
+ lib/Kavorka/Signature.pm                    | 40 +++++++++++++++++++++++++++++++++++++---
+ lib/Kavorka/TraitFor/Parameter/alias.pm     | 19 +++++++++++++++++--
+ lib/Kavorka/TraitFor/Parameter/ref_alias.pm | 19 +++++++++++++++++--
+ 3 files changed, 71 insertions(+), 7 deletions(-)
+
+diff --git a/lib/Kavorka/Signature.pm b/lib/Kavorka/Signature.pm
+index c9b8675..32e9e69 100644
+--- a/lib/Kavorka/Signature.pm
++++ b/lib/Kavorka/Signature.pm
+@@ -19,6 +19,8 @@ use Parse::KeywordX;
+ use Moo;
+ use namespace::sweep;
+ 
++use constant HAS_REFALIASING => ($] >= 5.022);
++
+ has package           => (is => 'ro');
+ has _is_dummy         => (is => 'ro');
+ has params            => (is => 'ro',  default => sub { +[] });
+@@ -276,13 +278,45 @@ sub _injection_hash_underscore
+ 	or $slurpy && $slurpy->name =~ /\A\%/
+ 	or $slurpy && $slurpy->name =~ /\A\$/ && $slurpy->type->is_a_type_of(Types::Standard::HashRef()))
+ 	{
+-		require Data::Alias;
+ 		my $ix  = 1 + $self->last_position;
+-		my $str = sprintf(
++		my $str;
++		if (HAS_REFALIASING) {
++			my $format = <<'EOF';
++local %%_;
++{
++	use Carp qw(croak);
++	use experimental 'refaliasing';
++
++	if ($#_==%d && ref($_[%d]) eq q(HASH)) {
++		\%%_ = \%%{$_[%d]};
++	}
++	else {
++		# Make a hash reference from array refalias does not work
++		# Manual build
++		my $slice_length = ($#_ + 1 - %d);
++		if ($slice_length %% 2 != 0) {
++			# Seems to be what t/10positional.t wants
++			croak("Odd number of elements in anonymous hash");
++		}
++		my $i = %d;
++		while ($i <= $#_) {
++			my $key = $_[$i];
++			\$_{$key} = \$_[$i+1];
++			$i += 2;
++		}
++	}
++};
++EOF
++			$str = sprintf($format,($ix) x 5,);
++		}
++		else {
++			require Data::Alias;
++			$str = sprintf(
+ 			'local %%_; { use warnings FATAL => qw(all); Data::Alias::alias(%%_ = ($#_==%d && ref($_[%d]) eq q(HASH)) ? %%{$_[%d]} : @_[ %d .. $#_ ]) };',
+ 			($ix) x 4,
+ 		);
+-		
++		}
++
+ 		unless ($slurpy or $self->yadayada)
+ 		{
+ 			my @allowed_names = map +($_=>1), map @{$_->named_names}, $self->named_params;
+diff --git a/lib/Kavorka/TraitFor/Parameter/alias.pm b/lib/Kavorka/TraitFor/Parameter/alias.pm
+index 4120d37..c639391 100644
+--- a/lib/Kavorka/TraitFor/Parameter/alias.pm
++++ b/lib/Kavorka/TraitFor/Parameter/alias.pm
+@@ -9,6 +9,8 @@ our $VERSION   = '0.035';
+ 
+ use Moo::Role;
+ 
++use constant HAS_REFALIASING => ($] >= 5.022);
++
+ around _injection_assignment => sub
+ {
+ 	my $next = shift;
+@@ -17,8 +19,21 @@ around _injection_assignment => sub
+ 	
+ 	if ($self->kind eq 'my')
+ 	{
+-		require Data::Alias;
+-		return sprintf('Data::Alias::alias(my %s = do { %s });', $var, $val);
++		my $format;
++		if (HAS_REFALIASING) {
++			$format = <<'EOF';
++my %s;
++{
++	use experimental 'refaliasing';
++	\%s = \do { %s };
++};
++EOF
++			return sprintf($format, ($var) x 2, $val);
++		}
++		else {
++			require Data::Alias;
++			return sprintf('Data::Alias::alias(my %s = do { %s });', $var, $val);
++		}
+ 	}
+ 	elsif ($self->kind eq 'our')
+ 	{
+diff --git a/lib/Kavorka/TraitFor/Parameter/ref_alias.pm b/lib/Kavorka/TraitFor/Parameter/ref_alias.pm
+index adae6ae..169d132 100644
+--- a/lib/Kavorka/TraitFor/Parameter/ref_alias.pm
++++ b/lib/Kavorka/TraitFor/Parameter/ref_alias.pm
+@@ -9,6 +9,8 @@ our $VERSION   = '0.035';
+ 
+ use Moo::Role;
+ 
++use constant HAS_REFALIASING => ($] >= 5.022);
++
+ around _injection_assignment => sub
+ {
+ 	my $next = shift;
+@@ -17,8 +19,21 @@ around _injection_assignment => sub
+ 	
+ 	if ($self->kind eq 'my')
+ 	{
+-		require Data::Alias;
+-		return sprintf('Data::Alias::alias(my %s = %s{ +do { %s } });', $var, $self->sigil, $val);
++		my $format;
++		if (HAS_REFALIASING) {
++			$format = <<'EOF';
++my %s;
++{
++	use experimental 'refaliasing';
++	\%s = \%s{ +do { %s } };
++};
++EOF
++			return sprintf($format, ($var) x 2, $self->sigil, $val);
++		}
++		else {
++			require Data::Alias;
++			return sprintf('Data::Alias::alias(my %s = %s{ +do { %s } });', $var, $self->sigil, $val);
++		}
+ 	}
+ 	elsif ($self->kind eq 'our')
+ 	{
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..ceed685
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+remove-data-alias-dependency.patch
diff --git a/debian/rules b/debian/rules
index 2a9fc37..d935869 100755
--- a/debian/rules
+++ b/debian/rules
@@ -28,7 +28,7 @@ DEB_UPSTREAM_URL = http://www.cpan.org/authors/id/T/TO/TOBYINK
 
 # Needed by upstream build and (always) at runtime
 #  * Recent Scalar::List::Utils needed for Sub::Util
-perl-deps = data-alias exporter-tiny module-runtime padwalker
+perl-deps = exporter-tiny module-runtime padwalker
 perl-deps += parse-keyword return-type type-tiny
 perl-deps += match-simple namespace-sweep
 deps = $(patsubst %,$(comma) lib%-perl,$(perl-deps))

-- 
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6  2AAD CC1E 9E5B 7A6F E2DF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 324 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20161214/6d2c9b63/attachment.sig>


More information about the pkg-perl-maintainers mailing list