r64181 - in /trunk/libtry-tiny-perl: ./ debian/ debian/patches/ debian/source/ lib/Try/ t/
ansgar at users.alioth.debian.org
ansgar at users.alioth.debian.org
Sat Oct 23 11:48:40 UTC 2010
Author: ansgar
Date: Sat Oct 23 11:48:32 2010
New Revision: 64181
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64181
Log:
* New upstream release.
* Patch fix-pod-spelling.patch has been applied upstream.
* Use source format 3.0 (quilt); drop README.source and quilt framework.
* Bump standards-Version to 3.9.1.
* Update my email address.
Added:
trunk/libtry-tiny-perl/debian/source/
trunk/libtry-tiny-perl/debian/source/format
Removed:
trunk/libtry-tiny-perl/SIGNATURE
trunk/libtry-tiny-perl/debian/README.source
trunk/libtry-tiny-perl/debian/patches/
Modified:
trunk/libtry-tiny-perl/Changes
trunk/libtry-tiny-perl/MANIFEST
trunk/libtry-tiny-perl/META.yml
trunk/libtry-tiny-perl/Makefile.PL
trunk/libtry-tiny-perl/debian/changelog
trunk/libtry-tiny-perl/debian/control
trunk/libtry-tiny-perl/debian/copyright
trunk/libtry-tiny-perl/debian/rules
trunk/libtry-tiny-perl/lib/Try/Tiny.pm
trunk/libtry-tiny-perl/t/basic.t
trunk/libtry-tiny-perl/t/finally.t
Modified: trunk/libtry-tiny-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/Changes?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/Changes (original)
+++ trunk/libtry-tiny-perl/Changes Sat Oct 23 11:48:32 2010
@@ -1,3 +1,7 @@
+0.07
+ - allow multiple finally blocks
+ - pass the error, if any, to finally blocks when called
+
0.06
- in t/given_when.t use a plan instead of done_testing for more backwards
compatibility
Modified: trunk/libtry-tiny-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/MANIFEST?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/MANIFEST (original)
+++ trunk/libtry-tiny-perl/MANIFEST Sat Oct 23 11:48:32 2010
@@ -8,4 +8,3 @@
t/given_when.t
t/when.t
META.yml Module meta-data (added by MakeMaker)
-SIGNATURE Public-key signature (added by MakeMaker)
Modified: trunk/libtry-tiny-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/META.yml?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/META.yml (original)
+++ trunk/libtry-tiny-perl/META.yml Sat Oct 23 11:48:32 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Try-Tiny
-version: 0.06
+version: 0.07
abstract: ~
author: []
license: unknown
Modified: trunk/libtry-tiny-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/Makefile.PL?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/Makefile.PL (original)
+++ trunk/libtry-tiny-perl/Makefile.PL Sat Oct 23 11:48:32 2010
@@ -8,7 +8,6 @@
NAME => 'Try::Tiny',
VERSION_FROM => 'lib/Try/Tiny.pm',
INSTALLDIRS => 'site',
- SIGN => 1,
PL_FILES => { },
PREREQ_PM => {
'Test::More' => 0,
Modified: trunk/libtry-tiny-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/debian/changelog?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/debian/changelog (original)
+++ trunk/libtry-tiny-perl/debian/changelog Sat Oct 23 11:48:32 2010
@@ -1,15 +1,16 @@
-libtry-tiny-perl (0.06-1) UNRELEASED; urgency=low
-
- [ Jonathan Yu ]
- Documentation fixes only
- IGNORE-VERSION: 0.06-1
-
- * New upstream release
+libtry-tiny-perl (0.07-1) unstable; urgency=low
[ gregor herrmann ]
* debian/rules: switch order of arguments to dh.
- -- Jonathan Yu <jawnsy at cpan.org> Thu, 27 May 2010 19:52:13 -0400
+ [ Ansgar Burchardt ]
+ * New upstream release.
+ * Patch fix-pod-spelling.patch has been applied upstream.
+ * Use source format 3.0 (quilt); drop README.source and quilt framework.
+ * Bump standards-Version to 3.9.1.
+ * Update my email address.
+
+ -- Ansgar Burchardt <ansgar at debian.org> Sat, 23 Oct 2010 13:45:51 +0200
libtry-tiny-perl (0.04-1) unstable; urgency=low
Modified: trunk/libtry-tiny-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/debian/control?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/debian/control (original)
+++ trunk/libtry-tiny-perl/debian/control Sat Oct 23 11:48:32 2010
@@ -1,11 +1,11 @@
Source: libtry-tiny-perl
Section: perl
Priority: optional
-Build-Depends: debhelper (>= 7.0.8), quilt (>= 0.46-7)
+Build-Depends: debhelper (>= 7)
Build-Depends-Indep: perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Ansgar Burchardt <ansgar at 43-1.org>, Jonathan Yu <jawnsy at cpan.org>
-Standards-Version: 3.8.3
+Uploaders: Ansgar Burchardt <ansgar at debian.org>, Jonathan Yu <jawnsy at cpan.org>
+Standards-Version: 3.9.1
Homepage: http://search.cpan.org/dist/Try-Tiny/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libtry-tiny-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libtry-tiny-perl/
Modified: trunk/libtry-tiny-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/debian/copyright?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/debian/copyright (original)
+++ trunk/libtry-tiny-perl/debian/copyright Sat Oct 23 11:48:32 2010
@@ -1,4 +1,4 @@
-Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
Maintainer: Yuval Kogman <nothingmuch at woobling.org>
Source: http://search.cpan.org/dist/Try-Tiny/
Name: Try-Tiny
@@ -9,7 +9,7 @@
Files: debian/*
Copyright: 2010, Jonathan Yu <jawnsy at cpan.org>
- 2009, Ansgar Burchardt <ansgar at 43-1.org>
+ 2009, Ansgar Burchardt <ansgar at debian.org>
License: MIT
License: MIT
Modified: trunk/libtry-tiny-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/debian/rules?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/debian/rules (original)
+++ trunk/libtry-tiny-perl/debian/rules Sat Oct 23 11:48:32 2010
@@ -1,4 +1,4 @@
#!/usr/bin/make -f
%:
- dh $@ --with quilt
+ dh $@
Added: trunk/libtry-tiny-perl/debian/source/format
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/debian/source/format?rev=64181&op=file
==============================================================================
--- trunk/libtry-tiny-perl/debian/source/format (added)
+++ trunk/libtry-tiny-perl/debian/source/format Sat Oct 23 11:48:32 2010
@@ -1,0 +1,1 @@
+3.0 (quilt)
Modified: trunk/libtry-tiny-perl/lib/Try/Tiny.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/lib/Try/Tiny.pm?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/lib/Try/Tiny.pm (original)
+++ trunk/libtry-tiny-perl/lib/Try/Tiny.pm Sat Oct 23 11:48:32 2010
@@ -10,7 +10,7 @@
@ISA = qw(Exporter);
}
-$VERSION = "0.06";
+$VERSION = "0.07";
$VERSION = eval $VERSION;
@@ -29,7 +29,7 @@
# to $failed
my $wantarray = wantarray;
- my ( $catch, $finally );
+ my ( $catch, @finally );
# find labeled blocks in the argument list.
# catch and finally tag the blocks by blessing a scalar reference to them.
@@ -41,7 +41,7 @@
if ( $ref eq 'Try::Tiny::Catch' ) {
$catch = ${$code_ref};
} elsif ( $ref eq 'Try::Tiny::Finally' ) {
- $finally = ${$code_ref};
+ push @finally, ${$code_ref};
} else {
use Carp;
confess("Unknown code ref type given '${ref}'. Check your usage & try again");
@@ -85,7 +85,9 @@
}
# set up a scope guard to invoke the finally block at the end
- my $guard = $finally && bless \$finally, "Try::Tiny::ScopeGuard";
+ my @guards =
+ map { Try::Tiny::ScopeGuard->_new($_, $failed ? $error : ()) }
+ @finally;
# at this point $failed contains a true value if the eval died, even if some
# destructor overwrote $@ as the eval was unwinding.
@@ -127,9 +129,19 @@
);
}
-sub Try::Tiny::ScopeGuard::DESTROY {
- my $self = shift;
- $$self->();
+{
+ package Try::Tiny::ScopeGuard;
+
+ sub _new {
+ shift;
+ bless [ @_ ];
+ }
+
+ sub DESTROY {
+ my @guts = @{ shift() };
+ my $code = shift @guts;
+ $code->(@guts);
+ }
}
__PACKAGE__
@@ -192,7 +204,8 @@
try { die 'foo' } catch { warn "Got a die: $_" } finally { $x = 'bar' };
Finally blocks are always executed making them suitable for cleanup code
-which cannot be handled using local.
+which cannot be handled using local. You can add as many finally blocks to a
+given try block as you like.
=head1 EXPORTS
@@ -266,6 +279,22 @@
executed in the event of a successful C<try> or if C<catch> is run. This allows
you to locate cleanup code which cannot be done via C<local()> e.g. closing a file
handle.
+
+When invoked, the finally block is passed the error that was caught. If no
+error was caught, it is passed nothing. In other words, the following code
+does just what you would expect:
+
+ try {
+ die_sometimes();
+ } catch {
+ # ...code run in case of error
+ } finally {
+ if (@_) {
+ print "The try block died with: @_\n";
+ } else {
+ print "The try block ran without error.\n";
+ }
+ };
B<You must always do your own error handling in the finally block>. C<Try::Tiny> will
not do anything about handling possible errors coming from code located in these
@@ -394,11 +423,21 @@
=item *
-C<@_> is not available, you need to name your args:
+C<@_> is not available within the C<try> block, so you need to copy your
+arglist. In case you want to work with argument values directly via C<@_>
+aliasing (i.e. allow C<$_[1] = "foo">), you need to pass C<@_> by reference:
sub foo {
my ( $self, @args ) = @_;
try { $self->bar(@args) }
+ }
+
+or
+
+ sub bar_in_place {
+ my $self = shift;
+ my $args = \@_;
+ try { $_ = $self->bar($_) for @$args }
}
=item *
Modified: trunk/libtry-tiny-perl/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/t/basic.t?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/t/basic.t (original)
+++ trunk/libtry-tiny-perl/t/basic.t Sat Oct 23 11:48:32 2010
@@ -82,6 +82,9 @@
{
my ($sub) = catch { my $a = $_; };
is(ref($sub), 'Try::Tiny::Catch', 'Checking catch subroutine scalar reference is correctly blessed');
+}
+
+{
my ($sub) = finally { my $a = $_; };
is(ref($sub), 'Try::Tiny::Finally', 'Checking finally subroutine scalar reference is correctly blessed');
}
Modified: trunk/libtry-tiny-perl/t/finally.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtry-tiny-perl/t/finally.t?rev=64181&op=diff
==============================================================================
--- trunk/libtry-tiny-perl/t/finally.t (original)
+++ trunk/libtry-tiny-perl/t/finally.t Sat Oct 23 11:48:32 2010
@@ -3,7 +3,7 @@
use strict;
#use warnings;
-use Test::More tests => 8;
+use Test::More tests => 12;
BEGIN { use_ok 'Try::Tiny' };
@@ -38,5 +38,28 @@
pass('Moved into finally block when try throws an exception and we have no catch block');
};
+try {
+ die('Die');
+} finally {
+ pass('First finally clause run');
+} finally {
+ pass('Second finally clause run');
+};
+
+try {
+ # do not die
+} finally {
+ if (@_) {
+ fail("errors reported: @_");
+ } else {
+ pass("no error reported") ;
+ }
+};
+
+try {
+ die("Die\n");
+} finally {
+ is_deeply(\@_, [ "Die\n" ], "finally got passed the exception");
+};
1;
More information about the Pkg-perl-cvs-commits
mailing list