diff --git a/Changes b/Changes index 561cd055d..35fe7aa1a 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,7 @@ - fix modulo for ulonglong and on Windows - update Opt::Simplex docs (#452) - thanks @KJ7LNW - fix Graphics::OpenGLQ on MacOS Ventura (#452) - thanks @deriamis +- fix IO::Storable warning on empty (#448) - thanks @djerius for report 2.084 2023-05-21 - reduce size of PDL_KLUDGE_COPY_X macro to <4096 in line with C standard, to fix for older clang on many BSD diff --git a/IO/Storable/storable.pd b/IO/Storable/storable.pd index 4f0be1ecd..da2ec0e80 100644 --- a/IO/Storable/storable.pd +++ b/IO/Storable/storable.pd @@ -36,16 +36,8 @@ void make_null(sv) SV *sv CODE: - /* we basically mimic pdl_null but without letting - * it give us a it->sv ! We have our own to which we - * connect below - */ pdl *it = PDL->pdlnew(); if (!it) PDL->pdl_barf("Failed to create new pdl"); - it->datatype = PDL_B; - it->data = PDL->smalloc((STRLEN) (PDL->howbig(it->datatype))); - it->datasv = newSVpv(it->data,PDL->howbig(it->datatype)); - it->data = SvPV_nolen((SV *)it->datasv); /* connect pdl struct to this sv */ sv_setiv(SvRV(sv),PTR2IV(it)); it->sv = SvRV(sv); diff --git a/IO/Storable/t/storable.t b/IO/Storable/t/storable.t index 8189f735a..2da9ed028 100644 --- a/IO/Storable/t/storable.t +++ b/IO/Storable/t/storable.t @@ -16,7 +16,12 @@ $serialized = freeze $x; $oldx = thaw $serialized; # $oldx->dump; -ok(sum(abs($x-$oldx))==0, 'PDL freeze/thaw'); +is sum(abs($x-$oldx)), 0, 'PDL freeze/thaw'; + +$x = double '1'; +$serialized = freeze $x; +$dthaw = thaw $serialized; +is $dthaw, $x, 'PDL freeze/thaw of PDL scalar'; # $oldb = thaw $serialized; # $oldc = thaw $serialized; @@ -49,7 +54,7 @@ $pfreeze = $phash->freeze; $phthaw = thaw $pfreeze; ok(all($phthaw == $phash), 'PDL has-a works with freeze/thaw'); -ok(UNIVERSAL::isa($phthaw,'HASH'), 'PDL is a hash'); +isa_ok($phthaw,'HASH', 'PDL is a hash'); # Test that freeze + thaw results in new object $seq1 = sequence(3); @@ -66,6 +71,12 @@ $seq2->slice('2') .= 8; ok(! all($seq2 == $seq2_dc), 'Initialization from dclone object') or diag($seq2, $seq2_dc); +{ + my @w; + local $SIG{__WARN__} = sub { push @w, @_ }; + thaw( freeze pdl([]) ); + is "@w", '', 'no warnings'; +} # Now test reading from files testLoad($_) foreach( qw(t/storable_new_amd64.dat t/storable_old_amd64.dat) );