From c884f1553dd6f27cd29742032e2ef48b68ae0ee9 Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Wed, 15 Apr 2026 08:52:29 +0000 Subject: [PATCH 1/4] fix: add DESTROY guard, modernize Digest::file, document digest_file_ctx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add empty DESTROY to Digest.pm to prevent AUTOLOAD from catching implicit DESTROY calls during garbage collection. Replace @ISA with use parent in Digest::file — the last module still using the legacy pattern. Document digest_file_ctx() in POD — it was exported but undocumented. Add tests for both changes. Co-Authored-By: Claude Opus 4.6 --- lib/Digest.pm | 2 ++ lib/Digest/file.pm | 18 +++++++++++++++--- t/digest.t | 5 ++++- t/file.t | 20 ++++++++++++++++++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lib/Digest.pm b/lib/Digest.pm index b62ef64..087274a 100644 --- a/lib/Digest.pm +++ b/lib/Digest.pm @@ -64,6 +64,8 @@ sub AUTOLOAD { $class->new( $algorithm, @_ ); } +sub DESTROY { } # prevent AUTOLOAD from catching implicit DESTROY calls + 1; __END__ diff --git a/lib/Digest/file.pm b/lib/Digest/file.pm index 088fabf..dd44c32 100644 --- a/lib/Digest/file.pm +++ b/lib/Digest/file.pm @@ -3,12 +3,11 @@ package Digest::file; use strict; use warnings; -use Exporter (); +use parent 'Exporter'; use Carp qw(croak); use Digest (); our $VERSION = "1.20"; -our @ISA = qw(Exporter); our @EXPORT_OK = qw(digest_file_ctx digest_file digest_file_hex digest_file_base64); sub digest_file_ctx { @@ -52,11 +51,24 @@ Digest::file - Calculate digests of files =head1 DESCRIPTION -This module provide 3 convenience functions to calculate the digest +This module provide 4 convenience functions to calculate the digest of files. The following functions are provided: =over +=item digest_file_ctx( $file, $algorithm, [$arg,...] ) + +This function will open the given file in binary mode, feed its +contents to a new digest object, and return the L context +object. This is useful when you need to call a specific digest +method yourself rather than using one of the shorthand functions +below. The function will croak if no algorithm is specified or if +it fails to open or read the file. + +The $algorithm is a string like "MD2", "MD5", "SHA-1", "SHA-512". +Additional arguments are passed to the constructor for the +implementation of the given algorithm. + =item digest_file( $file, $algorithm, [$arg,...] ) This function will calculate and return the binary digest of the bytes diff --git a/t/digest.t b/t/digest.t index 941f21d..0f5dfe4 100644 --- a/t/digest.t +++ b/t/digest.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 5; # To find Digest::Dummy use lib 't/lib'; @@ -22,3 +22,6 @@ is $d->digest, "ooo"; $Digest::MMAP{"Dummy-24"} = [ ["NotThere"], "NotThereEither", [ "Digest::Dummy", 24 ] ]; $d = Digest->new("Dummy-24"); is $d->digest, "24"; + +# DESTROY should not trigger AUTOLOAD +ok( Digest->can("DESTROY"), "Digest has explicit DESTROY method" ); diff --git a/t/file.t b/t/file.t index 48ef39d..b83a563 100644 --- a/t/file.t +++ b/t/file.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 9; use File::Temp 'tempfile'; @@ -32,7 +32,7 @@ use File::Temp 'tempfile'; } } -use Digest::file qw(digest_file digest_file_hex digest_file_base64); +use Digest::file qw(digest_file_ctx digest_file digest_file_hex digest_file_base64); { my ( $fh, $file ) = tempfile( UNLINK => 1 ); @@ -52,5 +52,21 @@ use Digest::file qw(digest_file digest_file_hex digest_file_base64); } } +# digest_file_ctx returns a usable Digest context object +{ + my ( $fh2, $file2 ) = tempfile( UNLINK => 1 ); + binmode($fh2); + print $fh2 "test data"; + close($fh2) || die "Can't write '$file2': $!"; + + my $ctx = digest_file_ctx( $file2, "Foo" ); + isa_ok( $ctx, "Digest::Foo", "digest_file_ctx returns correct class" ); + is( $ctx->digest, "0009", "digest_file_ctx feeds file content to context" ); +} + +# Error handling +ok !eval { digest_file_ctx( "not-there.txt", "Foo" ) }; +like $@, qr/Can't open/, "digest_file_ctx croaks on missing file"; + ok !eval { digest_file( "not-there.txt", "Foo" ) }; ok $@; From 53571cb5a68b125573e43ac135a0e8f3ecc3be4b Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Wed, 15 Apr 2026 08:53:50 +0000 Subject: [PATCH 2/4] fix: use base instead of parent for Perl 5.006 compat parent.pm was added in 5.10.1 but MIN_PERL_VERSION is 5.006. base.pm is available since 5.004005 and consistent with Digest::base's own POD example. Co-Authored-By: Claude Opus 4.6 --- lib/Digest/file.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Digest/file.pm b/lib/Digest/file.pm index dd44c32..1bcfff0 100644 --- a/lib/Digest/file.pm +++ b/lib/Digest/file.pm @@ -3,7 +3,7 @@ package Digest::file; use strict; use warnings; -use parent 'Exporter'; +use base 'Exporter'; use Carp qw(croak); use Digest (); From 83ce8a2100a62d0c0ea02f63c24c73c02acb787b Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Sat, 11 Apr 2026 12:28:23 +0000 Subject: [PATCH 3/4] ci: fix broken test matrix and update actions Docker Hub deprecated Image Format v1, breaking pulls for perl:5.8 through perl:5.24 containers on GitHub Actions. This caused all CI runs (including main branch) to fail on those versions. - Remove Perl 5.8-5.24 from matrix (Docker images no longer pullable) - Add Perl 5.34, 5.36, 5.38, 5.40 to matrix - Update actions/checkout from v2 to v4 The module still supports Perl 5.006+ at runtime; only CI coverage of versions older than 5.26 is affected by this infrastructure change. Supersedes #14 and #15. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/testsuite.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index 3cd0e3e..aae57d9 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: perl -V - name: install dependencies uses: perl-actions/install-with-cpm@v1 @@ -46,26 +46,21 @@ jobs: matrix: perl-version: [ + "5.40", + "5.38", + "5.36", + "5.34", "5.32", "5.30", "5.28", "5.26", - "5.24", - "5.22", - "5.20", - "5.18", - "5.16", - "5.14", - "5.12", - "5.10", - "5.8", ] container: image: perl:${{ matrix.perl-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: perl -V - name: install dependencies uses: perl-actions/install-with-cpm@v1 @@ -93,7 +88,7 @@ jobs: perl-version: [latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: perl -V - name: install dependencies uses: perl-actions/install-with-cpm@v1 From c435d9259012ae4dd25820da421312f0a0ecaede Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Wed, 22 Apr 2026 12:44:02 +0000 Subject: [PATCH 4/4] ci: modernize CI matrix and add Windows testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidates CI improvements into a single change: - Remove Perl 5.8–5.24 from matrix (Docker Hub deprecated Image Format v1) - Add Perl 5.34, 5.36, 5.38, 5.40 to linux matrix - Update actions/checkout v2 → v4 (Node.js 12 → 20) - Add Windows CI job using Strawberry Perl Supersedes #14, #15, #18, and #20. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/testsuite.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index aae57d9..23e101e 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -72,6 +72,37 @@ jobs: - name: make test run: make test + windows: + needs: [ubuntu] + env: + PERL_USE_UNSAFE_INC: 0 + AUTHOR_TESTING: 1 + AUTOMATED_TESTING: 1 + RELEASE_TESTING: 1 + + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + perl-version: [latest] + + steps: + - uses: actions/checkout@v4 + - name: Set up Perl + uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: ${{ matrix.perl-version }} + - run: perl -V + - name: install dependencies + uses: perl-actions/install-with-cpm@v1 + with: + cpanfile: "cpanfile" + - name: Makefile.PL + run: perl Makefile.PL + - name: make test + run: gmake test + macOS: needs: [ubuntu] env: