Bug#894554: libdatetime-locale-perl: fails to deserialize (thaw) from Storable
Daniel Friesel
derf+debbugs at finalrewind.org
Sun Apr 1 11:01:44 UTC 2018
Package: libdatetime-locale-perl
Version: 1:1.17-1
Severity: normal
Hi,
When loading a DateTime / DateTime::Locale object which was previously
serialized using Storable, DateTime::Locale::FromData::STORABLE_thaw fails if
the code loading the Storable object does not import DateTime::Locale.
To reproduce:
> perl -MStorable -MDateTime::Locale -E 'my $loc = DateTime::Locale->load("en-GB"); store(\$loc, "/tmp/whatever.db")';
> perl -MStorable -E 'my $loc_ref = retrieve("/tmp/whatever.db"); say $$loc_ref->{code}'
Expected behaviour: The second line outputs "en-GB"
Actual behaviour: STORABLE_thaw throws an error:
> Can't locate object method "load" via package "DateTime::Locale" at
> /usr/share/perl5/DateTime/Locale/FromData.pm line 262
Workaround: Import DateTime or DateTime::Locale, e.g.
> perl -MStorable -MDateTime::Locale -E 'my $loc = DateTime::Locale->load("en-GB"); store(\$loc, "/tmp/whatever.db")';
> perl -MStorable -MDateTime::Locale -E 'my $loc_ref = retrieve("/tmp/whatever.db"); say $$loc_ref->{code}'
As far as I know, users should not be required to import DateTime::Locale when
deserializing an object containing locales, so this looks like a bug to me.
It can be fixed by importing the module in DateTime/Locale/FromData.pm:
> diff --git a/lib/DateTime/Locale/FromData.pm b/lib/DateTime/Locale/FromData.pm
> index fd9ab78a..7e6cd622 100644
> --- a/lib/DateTime/Locale/FromData.pm
> +++ b/lib/DateTime/Locale/FromData.pm
> @@ -4,6 +4,7 @@ use strict;
> use warnings;
> use namespace::autoclean;
>
> +use DateTime::Locale;
> use DateTime::Locale::Util qw( parse_locale_code );
> use Params::ValidationCompiler 0.13 qw( validation_for );
> use Specio::Declare;
Thank you for your work,
Daniel
-- System Information:
Debian Release: buster/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.15.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages libdatetime-locale-perl depends on:
ii libfile-sharedir-perl 1.104-1
ii libnamespace-autoclean-perl 0.28-1
ii libparams-validationcompiler-perl 0.27-1
ii libspecio-perl 0.42-1
ii perl 5.26.1-5
ii perl-base [libscalar-list-utils-perl] 5.26.1-5
libdatetime-locale-perl recommends no packages.
libdatetime-locale-perl suggests no packages.
-- no debconf information
More information about the pkg-perl-maintainers
mailing list