Bug 2264004 - Useless dependency on perl(PerlIO::utf8_strict)
Summary: Useless dependency on perl(PerlIO::utf8_strict)
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: perl-Path-Tiny
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paul Howarth
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-02-13 09:51 UTC by Petr Pisar
Modified: 2024-02-13 12:57 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-02-13 12:57:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Pisar 2024-02-13 09:51:16 UTC
I noticed these dependencies in perl-Path-Tiny-0.144-5.fc40:

# For performance and consistency
%if !(0%{?rhel})
BuildRequires:  perl(PerlIO::utf8_strict) >= 0.003
Requires:   perl(PerlIO::utf8_strict) >= 0.003
%endif
BuildRequires:  perl(Unicode::UTF8) >= 0.58
Requires:   perl(Unicode::UTF8) >= 0.58

In other words, this package build- and run-requires both perl(PerlIO::utf8_strict) and perl(Unicode::UTF8) on Fedora.

However a code in lib/Path/Tiny.pm never uses both of the modules:

my $HAS_UU; # has Unicode::UTF8; lazily populated
    
sub _check_UU {
    local $SIG{__DIE__}; # prevent outer handler from being called
    !!eval {
        require Unicode::UTF8; 
        Unicode::UTF8->VERSION(0.58);
        1;
    };
}   
    
my $HAS_PU;              # has PerlIO::utf8_strict; lazily populated

sub _check_PU {
    local $SIG{__DIE__}; # prevent outer handler from being called
    !!eval {
        # MUST preload Encode or $SIG{__DIE__} localization fails
        # on some Perl 5.8.8 (maybe other 5.8.*) compiled with -O2.
        require Encode;
        require PerlIO::utf8_strict;
        PerlIO::utf8_strict->VERSION(0.003);
        1;
    };
}
[...]
    if (   ( defined($HAS_UU) ? $HAS_UU : ( $HAS_UU = _check_UU() ) )
        && $args->{chomp}
        && !$args->{count} )
    {
        my $slurp = slurp_utf8($self);
        $slurp =~ s/$CRLF\z//; # like chomp, but full CR?LF|CR
        return split $CRLF, $slurp, -1; ## no critic
    }
    elsif ( defined($HAS_PU) ? $HAS_PU : ( $HAS_PU = _check_PU() ) ) {
        $args->{binmode} = ":raw:utf8_strict";
        return lines( $self, $args );
    }
    else {
        $args->{binmode} = ":raw:encoding(UTF-8)";
        return lines( $self, $args );
    }

I recommend removing the never used dependency on perl(PerlIO::utf8_strict).

Please note that the tests attempts to exhibit both code paths by masking the other module. However, performing the tests in Fedora is dubious if we never use PerlIO::utf8_strict if Unicode::UTF8 is available at run-time.

Comment 1 Paul Howarth 2024-02-13 11:36:01 UTC
You are right that append_utf8 uses Unicode::UTF8 in preference to PerlIO::utf8_strict.

However, in edit_lines_utf8 and open*_utf8, PerlIO::utf8_strict is used if available and there is no optimized version using Unicode::UTF8:

sub edit_lines_utf8 {
    if ( defined($HAS_PU) ? $HAS_PU : ( $HAS_PU = _check_PU() ) ) {
        $_[2] = { binmode => ":raw:utf8_strict" };
    }
    else {
        $_[2] = { binmode => ":raw:encoding(UTF-8)" };
    }
    goto &edit_lines;
}

So I think it's not right to say that PerlIO::utf8_strict is never used in the presence of Unicode::UTF8.

Comment 2 Petr Pisar 2024-02-13 12:57:37 UTC
You are right. That's silly.


Note You need to log in before you can comment on or make changes to this bug.