Bug#1078094: libcatmandu-perl: Catmandu::Util warns on usage with Perl 5.40: Attempt to call undefined import method with arguments

Niko Tyni ntyni at debian.org
Sat Aug 24 14:50:26 BST 2024


On Tue, Aug 06, 2024 at 11:45:36PM +0300, Niko Tyni wrote:
> Package: libcatmandu-perl
> Version: 1.2021-1
> Severity: important
> User: debian-perl at lists.debian.org
> Usertags: perl-5.40-transition
> 
> The Catmandu::Util module in this package warns on usage with Perl 5.40
> (currently in experimental).  This causes an autopkgtest regression in
> the libcatmandu-xsd-perl package, hence the severity.
> 
>   https://ci.debian.net/packages/libc/libcatmandu-xsd-perl/unstable/amd64/50042235/
> 
>   $ perl -w -e 'use Catmandu::XSD'
>   Attempt to call undefined import method with arguments ("is_string") via package "Catmandu::Util" (Perhaps you forgot to load the package?) at /usr/share/perl5/Catmandu/Error.pm line 47.
>   $ perl -w -e 'use Catmandu::Util'
>   Attempt to call undefined import method with arguments ("is_string") via package "Catmandu::Util" (Perhaps you forgot to load the package?) at /usr/share/perl5/Catmandu/Error.pm line 47.

While the warning above is correct, I suspect Catmandu::XSD is not meant
to be used alone like this, and a fix should really go there.

What happens here is that saying just 'use Catmandu::Util'
(as Catmandu::XSD does) first loads Catmandu::Sane which loads
Catmandu::Error which has 'use Catmandu::Util qw(is_string)'. This calls
Catmandu::Util->import('is_string') at compile time, but the module does
not even have an import method yet  - it would have been installed next
with a 'use Exporter qw(import)' call.

Swapping those lines to bring in the import method first leads to a next
problem: all the Exporter tags are installed at run time. The best "fix"
I found was to move the whole loading of Catmandu::Sane to runtime,
and moving the EXPORT_* modifications to compile time with BEGIN{}
blocks. (See the "Playing Safe" section in Exporter(3perl) for more
information about runtime/compile time traps with Exporter.)

I'm attaching a proof of concept patch for this to show what it might take
to fix this. But I don't really expect this to be applied.  I suspect that
making 'use Catmandu::XSD' work alone is a non-goal and our testing should
really run something like 'catmandu convert XSD ...' which presumably
loads Catmandu::XSD behind the scenes. This probably applies to Catmandu
itself too.

Lacking that, perhaps we should just disable the current test, or allow
it to generate warnings (which may just postpone this issue until the
deprecation becomes a hard error.) I suppose we shouldn't be slaves to
our QA checks when they pinpoint things that nobody really cares about.

I'd appreciate it if somebody else looked at this too, and perhaps
reassigned this to libcatmandu-xsd-perl if they agree. We won't be able
to get Perl 5.40 in without doing something about this.
-- 
Niko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-Catmandu-Util-loadable-alone-without-warnings.patch
Type: text/x-diff
Size: 2332 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-perl-maintainers/attachments/20240824/c8cc52f7/attachment.patch>


More information about the pkg-perl-maintainers mailing list