r39166 - in /trunk/libdevel-stacktrace-perl: Changes META.yml Makefile.PL README SIGNATURE debian/changelog lib/Devel/StackTrace.pm t/01-basic.t
nhandler-guest at users.alioth.debian.org
nhandler-guest at users.alioth.debian.org
Thu Jul 2 20:52:53 UTC 2009
Author: nhandler-guest
Date: Thu Jul 2 20:52:47 2009
New Revision: 39166
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=39166
Log:
Update to 1.2100
Modified:
trunk/libdevel-stacktrace-perl/Changes
trunk/libdevel-stacktrace-perl/META.yml
trunk/libdevel-stacktrace-perl/Makefile.PL
trunk/libdevel-stacktrace-perl/README
trunk/libdevel-stacktrace-perl/SIGNATURE
trunk/libdevel-stacktrace-perl/debian/changelog
trunk/libdevel-stacktrace-perl/lib/Devel/StackTrace.pm
trunk/libdevel-stacktrace-perl/t/01-basic.t
Modified: trunk/libdevel-stacktrace-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/Changes?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/Changes (original)
+++ trunk/libdevel-stacktrace-perl/Changes Thu Jul 2 20:52:47 2009
@@ -1,3 +1,14 @@
+1.21 Jul 1, 2009
+
+- Overloaded objects which didn't provide a stringification method
+ cause Devel::StackTrace to die when respect_overload was
+ true. Reported by Laurent Dami. RT #39533.
+
+- Added a frame_filter option which allows for fine-grained control
+ over what frames are included in a trace. Based on (but expanded)
+ from a patch proposed by Florian Ragwitz. RT #47415.
+
+
1.20 Oct 25, 2008
- The change in 1.15 to object creation broke the no_refs feature,
Modified: trunk/libdevel-stacktrace-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/META.yml?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/META.yml (original)
+++ trunk/libdevel-stacktrace-perl/META.yml Thu Jul 2 20:52:47 2009
@@ -1,6 +1,6 @@
---
name: Devel-StackTrace
-version: 1.20
+version: 1.21
author:
- 'Dave Rolsky, <autarch at urth.org>'
abstract: Stack trace and stack trace frame objects
@@ -15,8 +15,8 @@
provides:
Devel::StackTrace:
file: lib/Devel/StackTrace.pm
- version: 1.20
-generated_by: Module::Build version 0.3
+ version: 1.21
+generated_by: Module::Build version 0.32
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Modified: trunk/libdevel-stacktrace-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/Makefile.PL?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/Makefile.PL (original)
+++ trunk/libdevel-stacktrace-perl/Makefile.PL Thu Jul 2 20:52:47 2009
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.30
+# Note: this file was auto-generated by Module::Build::Compat version 0.32
require 5.006;
use ExtUtils::MakeMaker;
WriteMakefile
@@ -11,7 +11,6 @@
'Test::More' => '0.46'
},
'INSTALLDIRS' => 'site',
- 'EXE_FILES' => [],
- 'PL_FILES' => {}
+ 'EXE_FILES' => []
)
;
Modified: trunk/libdevel-stacktrace-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/README?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/README (original)
+++ trunk/libdevel-stacktrace-perl/README Thu Jul 2 20:52:47 2009
@@ -28,7 +28,7 @@
The Devel::StackTrace object contains a set of Devel::StackTraceFrame
objects, one for each level of the stack. The frames contain all the
- data available from "caller()".
+ data available from `caller()'.
This code was created to support my Exception::Class::Base class (part
of Exception::Class) but may be useful in other contexts.
@@ -53,19 +53,33 @@
}
Devel::StackTrace METHODS
- * Devel::StackTrace->new(%named_params)
-
+ * Devel::StackTrace->new(%named_params)
Returns a new Devel::StackTrace object.
Takes the following parameters:
- * ignore_package => $package_name OR \@package_names
+ * frame_filter => $sub
+ By default, Devel::StackTrace will include all stack frames
+ before the call to its its constructor.
+ However, you may want to filter out some frames with more
+ granularity than 'ignore_package' or 'ignore_class' allow.
+
+ You can provide a subroutine which is called with the raw
+ frame data for each frame. This is a hash reference with two
+ keys, "caller", and "args", both of which are array
+ references. The "caller" key is the raw data as returned by
+ Perl's `caller()' function, and the "args" key are the
+ subroutine arguments found in `@DB::args'.
+
+ The filter should return true if the frame should be
+ included, or false if it should be skipped.
+
+ * ignore_package => $package_name OR \@package_names
Any frames where the package is one of these packages will
not be on the stack.
- * ignore_class => $package_name OR \@package_names
-
+ * ignore_class => $package_name OR \@package_names
Any frames where the package is a subclass of one of these
packages (or is the same package) will not be on the stack.
@@ -75,8 +89,7 @@
create a subclass of Devel::StackTrace it will not be
ignored.
- * no_refs => $boolean
-
+ * no_refs => $boolean
If this parameter is true, then Devel::StackTrace will not
store references internally when generating stacktrace
frames. This lets your objects go out of scope.
@@ -84,61 +97,52 @@
Devel::StackTrace replaces any references with their
stringified representation.
- * respect_overload => $boolean
-
- By default, Devel::StackTrace will call "overload::StrVal()"
+ * respect_overload => $boolean
+ By default, Devel::StackTrace will call `overload::StrVal()'
to get the underlying string representation of an object,
instead of respecting the object's stringification
overloading. If you would prefer to see the overloaded
representation of objects in stack traces, then set this
parameter to true.
- * max_arg_length => $integer
-
+ * max_arg_length => $integer
By default, Devel::StackTrace will display the entire
argument for each subroutine call. Setting this parameter
causes it to truncate the argument's string representation
if it is longer than this number of characters.
- * $trace->next_frame
-
+ * $trace->next_frame
Returns the next Devel::StackTraceFrame object down on the stack. If
it hasn't been called before it returns the first frame. It returns
undef when it reaches the bottom of the stack and then resets its
- pointer so the next call to "next_frame" or "prev_frame" will work
+ pointer so the next call to `next_frame' or `prev_frame' will work
properly.
- * $trace->prev_frame
-
+ * $trace->prev_frame
Returns the next Devel::StackTraceFrame object up on the stack. If
it hasn't been called before it returns the last frame. It returns
undef when it reaches the top of the stack and then resets its
- pointer so pointer so the next call to "next_frame" or "prev_frame"
+ pointer so pointer so the next call to `next_frame' or `prev_frame'
will work properly.
- * $trace->reset_pointer
-
- Resets the pointer so that the next call "next_frame" or
- "prev_frame" will start at the top or bottom of the stack, as
+ * $trace->reset_pointer
+ Resets the pointer so that the next call `next_frame' or
+ `prev_frame' will start at the top or bottom of the stack, as
appropriate.
- * $trace->frames
-
+ * $trace->frames
Returns a list of Devel::StackTraceFrame objects. The order they are
returned is from top (most recent) to bottom.
- * $trace->frame ($index)
-
+ * $trace->frame ($index)
Given an index, returns the relevant frame or undef if there is not
frame at that index. The index is exactly like a Perl array. The
first frame is 0 and negative indexes are allowed.
- * $trace->frame_count
-
+ * $trace->frame_count
Returns the number of frames in the trace object.
- * $trace->as_string
-
+ * $trace->as_string
Calls as_string on each frame from top to bottom, producing output
quite similar to the Carp module's cluck/confess methods.
@@ -146,34 +150,24 @@
See the caller documentation for more information on what these methods
return.
- * $frame->package
-
- * $frame->filename
-
- * $frame->line
-
- * $frame->subroutine
-
- * $frame->hasargs
-
- * $frame->wantarray
-
- * $frame->evaltext
-
+ * $frame->package
+ * $frame->filename
+ * $frame->line
+ * $frame->subroutine
+ * $frame->hasargs
+ * $frame->wantarray
+ * $frame->evaltext
Returns undef if the frame was not part of an eval.
- * $frame->is_require
-
+ * $frame->is_require
Returns undef if the frame was not part of a require.
- * $frame->args
-
+ * $frame->args
Returns the arguments passed to the frame. Note that any arguments
that are references are returned as references, not copies.
- * $frame->hints
-
- * $frame->bitmask
+ * $frame->hints
+ * $frame->bitmask
SUPPORT
Please submit bugs to the CPAN RT system at
Modified: trunk/libdevel-stacktrace-perl/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/SIGNATURE?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/SIGNATURE (original)
+++ trunk/libdevel-stacktrace-perl/SIGNATURE Thu Jul 2 20:52:47 2009
@@ -16,22 +16,22 @@
SHA1 7afddfc9acf24c266120ef5c2f7bd386d2d3901d .shipit
SHA1 e35fb27b937280dc6e1b2f441a59e47b68faa1d1 Build.PL
-SHA1 a454d582e94ca46316c818abfa36dcea056689f0 Changes
+SHA1 daf9224c5fb956ac691cc9993d997057352c6ea3 Changes
SHA1 f235ba4160673bcb7c9d58c2f09dbc7fc0efadea LICENSE
SHA1 9ed43409974a8b931e0e34af209d4f99ccc68d50 MANIFEST
-SHA1 283f44833e79b89be9cdd51b9de3264d92de2822 META.yml
-SHA1 b485f5171773c668c0c0604ebf436019f9b3412e Makefile.PL
-SHA1 2c9447514240fab2c68851da0e4f3dbbb2157767 README
-SHA1 c71c041da6c6c63e821eed2399c1e0b64284c784 lib/Devel/StackTrace.pm
-SHA1 4a59de3a5627f92d42f794edc9f00a37911b3e73 t/01-basic.t
+SHA1 bf5a7faa7ad012d99b60f4d335795128ebe880cc META.yml
+SHA1 d3fba80c75c76ffd9931e032698eb4d8f163e073 Makefile.PL
+SHA1 012ce979e725de9f869c8860160f2ad8c113112e README
+SHA1 12ae116b50eda7d99b68572ff3a294264613e538 lib/Devel/StackTrace.pm
+SHA1 72f07c9a4eb8b75e1a9968a7b396b57a51675c11 t/01-basic.t
SHA1 21a1538da8dbde54af7a1708fa2470dd74fe67fc t/02-bad-utf8.t
SHA1 9ade2293d6e5ea77d94532132c89cd205ea85ed7 t/kwalitee.t
SHA1 28a931f3b0c075d8d6c4ce47d5e89c3fdb19ed0f t/pod-coverage.t
SHA1 cec881e89926d320475f9de2b7fad02c2169f510 t/pod.t
-----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
+Version: GnuPG v1.4.9 (GNU/Linux)
-iD8DBQFJA8sa3Or3ZzQuifMRAk2uAJ0dELxZwEra89LrD/rvL7zqh2WJpgCfTI9l
-+ZZvLPKf52IJkyOVjsVMKKw=
-=4/ql
+iEYEARECAAYFAkpMPFwACgkQIgMCsV8qvRJYvwCeM0CazZnfr/RGLySI/LnP6IZ6
++YsAoJFeyDzP1NEnba41rHSB9cKgi7UV
+=H3+L
-----END PGP SIGNATURE-----
Modified: trunk/libdevel-stacktrace-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/debian/changelog?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/debian/changelog (original)
+++ trunk/libdevel-stacktrace-perl/debian/changelog Thu Jul 2 20:52:47 2009
@@ -1,4 +1,4 @@
-libdevel-stacktrace-perl (1.2000-2) UNRELEASED; urgency=low
+libdevel-stacktrace-perl (1.2100-1) UNRELEASED; urgency=low
[ gregor herrmann ]
* debian/control: Changed: Switched Vcs-Browser field to ViewSVN
@@ -8,9 +8,11 @@
* debian/control: update my email address.
[ Nathan Handler ]
- * debian/watch: Update to ignore development releases.
+ * New upstream release
+ * debian/watch:
+ - Update to ignore development releases.
- -- Rene Mayorga <rmayorga at debian.org> Tue, 20 Jan 2009 01:27:15 -0600
+ -- Nathan Handler <nhandler at ubuntu.com> Thu, 02 Jul 2009 20:52:27 +0000
libdevel-stacktrace-perl (1.2000-1) unstable; urgency=low
Modified: trunk/libdevel-stacktrace-perl/lib/Devel/StackTrace.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/lib/Devel/StackTrace.pm?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/lib/Devel/StackTrace.pm (original)
+++ trunk/libdevel-stacktrace-perl/lib/Devel/StackTrace.pm Thu Jul 2 20:52:47 2009
@@ -12,7 +12,7 @@
'""' => \&as_string,
fallback => 1;
-our $VERSION = '1.20';
+our $VERSION = '1.21';
sub new
@@ -68,8 +68,13 @@
if blessed $ref && $ref->isa('Exception::Class::Base');
return overload::StrVal($ref) unless $self->{respect_overload};
- # force stringification and let overloading do its thing
- return $ref . '';
+
+ local $@;
+ local $SIG{__DIE__};
+
+ my $str = eval { $ref . '' };
+
+ return $@ ? overload::StrVal($ref) : $str;
}
sub _ecb_hack
@@ -99,6 +104,22 @@
{
my $self = shift;
+ my $filter = $self->_make_frame_filter;
+
+ my $raw = delete $self->{raw};
+ for my $r ( @{$raw} )
+ {
+ next unless $filter->($r);
+
+ $self->_add_frame( $r->{caller}, $r->{args} );
+ }
+}
+
+my $default_filter = sub { 1 };
+sub _make_frame_filter
+{
+ my $self = shift;
+
my (@i_pack_re, %i_class);
if ( $self->{ignore_package} )
{
@@ -108,23 +129,29 @@
@i_pack_re = map { ref $_ ? $_ : qr/^\Q$_\E$/ } @{ $self->{ignore_package} };
}
+ my $p = __PACKAGE__;
+ push @i_pack_re, qr/^\Q$p\E$/;
+
if ( $self->{ignore_class} )
{
$self->{ignore_class} = [ $self->{ignore_class} ] unless ref $self->{ignore_class};
%i_class = map {$_ => 1} @{ $self->{ignore_class} };
}
- my $p = __PACKAGE__;
- push @i_pack_re, qr/^\Q$p\E$/;
-
- my $raw = delete $self->{raw};
- for my $r ( @{$raw} )
- {
- next if grep { $r->{caller}[0] =~ /$_/ } @i_pack_re;
- next if grep { $r->{caller}[0]->isa($_) } keys %i_class;
-
- $self->_add_frame( $r->{caller}, $r->{args} );
- }
+ my $user_filter = $self->{frame_filter};
+
+ return sub
+ {
+ return 0 if grep { $_[0]{caller}[0] =~ /$_/ } @i_pack_re;
+ return 0 if grep { $_[0]{caller}[0]->isa($_) } keys %i_class;
+
+ if ( $user_filter )
+ {
+ return $user_filter->( $_[0] );
+ }
+
+ return 1;
+ };
}
sub _add_frame
@@ -445,6 +472,23 @@
=over 8
+=item * frame_filter => $sub
+
+By default, Devel::StackTrace will include all stack frames before the
+call to its its constructor.
+
+However, you may want to filter out some frames with more granularity
+than 'ignore_package' or 'ignore_class' allow.
+
+You can provide a subroutine which is called with the raw frame data
+for each frame. This is a hash reference with two keys, "caller", and
+"args", both of which are array references. The "caller" key is the
+raw data as returned by Perl's C<caller()> function, and the "args"
+key are the subroutine arguments found in C<@DB::args>.
+
+The filter should return true if the frame should be included, or
+false if it should be skipped.
+
=item * ignore_package => $package_name OR \@package_names
Any frames where the package is one of these packages will not be on
Modified: trunk/libdevel-stacktrace-perl/t/01-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdevel-stacktrace-perl/t/01-basic.t?rev=39166&op=diff
==============================================================================
--- trunk/libdevel-stacktrace-perl/t/01-basic.t (original)
+++ trunk/libdevel-stacktrace-perl/t/01-basic.t Thu Jul 2 20:52:47 2009
@@ -1,17 +1,16 @@
use strict;
use warnings;
+use Devel::StackTrace;
use Test::More;
BEGIN
{
- my $tests = 37;
+ my $tests = 40;
eval { require Exception::Class };
$tests++ if ! $@ && $Exception::Class::VERSION >= 1.09;
plan tests => $tests;
-
- use_ok('Devel::StackTrace');
}
sub get_file_name { File::Spec->canonpath( (caller(0))[1] ) }
@@ -54,7 +53,7 @@
Trace begun at $test_file_name line 1012
main::baz(1, 2) called at $test_file_name line 1007
main::bar(1) called at $test_file_name line 1002
-main::foo at $test_file_name line 22
+main::foo at $test_file_name line 21
EOF
is( $trace->as_string, $trace_text, 'trace text' );
@@ -92,7 +91,7 @@
my $trace_text = <<"EOF";
Trace begun at $test_file_name line 1012
-main::baz at $test_file_name line 91
+main::baz at $test_file_name line 90
EOF
my $t = "$trace";
@@ -262,7 +261,7 @@
my $trace_text = <<"EOF";
Trace begun at $test_file_name line 1027
-main::max_arg_length('abcdefghij...') called at $test_file_name line 261
+main::max_arg_length('abcdefghij...') called at $test_file_name line 260
EOF
is( $trace->as_string, $trace_text, 'trace text' );
@@ -291,6 +290,23 @@
'non-refs are preserved properly in raw data as well' );
}
+{
+ my $trace = overload_no_stringify( CodeOverload->new() );
+
+ eval { $trace->as_string() };
+ is( $@, q{},
+ 'no error when respect_overload is true and object overloads but does not stringify' );
+}
+
+{
+ my $trace = Filter::foo();
+
+ my @frames = $trace->frames();
+ is( scalar @frames, 2, 'filtered trace has just 2 frames' );
+ is( $frames[0]->subroutine(), 'Devel::StackTrace::new', 'first subroutine' );
+ is( $frames[1]->subroutine(), 'Filter::bar', 'second subroutine (skipped Filter::foo)' );
+}
+
# This means I can move these lines down without constantly fiddling
# with the checks for line numbers in the tests.
@@ -325,6 +341,12 @@
Devel::StackTrace->new( max_arg_length => 10 );
}
+sub overload_no_stringify
+{
+ return Devel::StackTrace->new( no_refs => 1, respect_overload => 1 );
+}
+
+
package Test;
sub foo
@@ -414,3 +436,25 @@
{
Devel::StackTrace->new( no_refs => 1 );
}
+
+package CodeOverload;
+
+use overload '&{}' => sub { 'foo' };
+
+sub new
+{
+ my $class = shift;
+ return bless {}, $class;
+}
+
+package Filter;
+
+sub foo
+{
+ bar();
+}
+
+sub bar
+{
+ return Devel::StackTrace->new( frame_filter => sub { $_[0]{caller}[3] ne 'Filter::foo' } );
+}
More information about the Pkg-perl-cvs-commits
mailing list