CC: | nilsonsfj [...] cpan.org |
Subject: | [PATCH] Compatibility with CV-in-stash optimisation |
Please see the attached patch. It allows this module to pass its tests with bleadperl’s optimization.
From perl5276delta:
=head2 Subroutines no longer need typeglobs
Perl 5.22.0 introduced an optimization allowing subroutines to be stored in
packages as simple sub refs, not requiring a full typeglob (thus
potentially saving large amounts of memeory). However, the optimization
was flawed: it only applied to the main package.
This optimization has now been extended to all packages. This may break
compatibility with introspection code that looks inside stashes and expects
everything in them to be a typeglob.
When this optimization happens, the typeglob still notionally exists, so
accessing it will cause the stash entry to be upgraded to a typeglob. The
optimization does not apply to XSUBs or exported subroutines, and calling a
method will undo it, since method calls cache things in typeglobs.
Subject: | open_CxgjJEzQ.txt |
diff -rup Class-Serializer-0.04-0-orig/lib/Class/Serializer.pm Class-Serializer-0.04-0/lib/Class/Serializer.pm
--- Class-Serializer-0.04-0-orig/lib/Class/Serializer.pm 2015-11-30 11:08:54.000000000 -0800
+++ Class-Serializer-0.04-0/lib/Class/Serializer.pm 2018-01-28 16:38:22.000000000 -0800
@@ -61,7 +61,11 @@ sub as_string {
no strict 'refs';
# loads the relevant data structures
- while (my ($entry, $contents) = each %{"${target}::"}) {
+ while (my ($entry, $contents) = each %{"${target}::"}) {
+ if (ref \$contents ne 'GLOB') {
+ # Vivify a glob
+ $contents = *{"${target}::$entry"};
+ }
for my $type (qw|SCALAR ARRAY HASH CODE|) {
if (*{$contents}{$type}) {
next if ($type eq 'SCALAR' && !defined ${*{$contents}{$type}});