DBD::SQLite - RT#79576
- Audit and correct potential bugs associated with braindead reuse
of $1 on unsuccessful matches
+ - Fix incorrect warning/exception originator reported by carp*() and
+ throw_exception()
0.08209 2013-03-01 12:56 (UTC)
* New Features / Changes
use Carp ();
use namespace::clean ();
+$Carp::Internal{ (__PACKAGE__) }++;
+
sub __find_caller {
my ($skip_pattern, $class) = @_;
if $skip_class_data;
my $fr_num = 1; # skip us and the calling carp*
- my @f;
+
+ my (@f, $origin);
while (@f = caller($fr_num++)) {
+
+ next if
+ ( $f[3] eq '(eval)' or $f[3] =~ /::__ANON__$/ );
+
+ $origin ||= (
+ $f[3] =~ /^ (.+) :: ([^\:]+) $/x
+ and
+ ! $Carp::Internal{$1}
+ and
+ $2 !~ /^(?: throw_exception | carp | carp_unique | carp_once )$/x
+ ) ? $f[3] : undef;
+
if (
$f[0]->can('_skip_namespace_frames')
and
last if $f[0] !~ $skip_pattern;
}
- my ($ln, $calling) = @f # if empty - nothing matched - full stack
- ? ( "at $f[1] line $f[2]", $f[3] )
- : ( Carp::longmess(), '{UNKNOWN}' )
+ my $site = @f # if empty - nothing matched - full stack
+ ? "at $f[1] line $f[2]"
+ : Carp::longmess()
;
+ $origin ||= '{UNKNOWN}';
return (
- $ln,
- $calling =~ /::/ ? "$calling(): " : "$calling: ", # cargo-cult from Carp::Clan
+ $site,
+ $origin =~ /::/ ? "$origin(): " : "$origin: ", # cargo-cult from Carp::Clan
);
};
use warnings;
use DBIx::Class::Carp ();
+$Carp::Internal{ (__PACKAGE__) }++;
use overload
'""' => sub { shift->{msg} },
-#!/usr/bin/perl
-
use strict;
use warnings;
+# without this the stacktrace of $schema will be activated
+BEGIN { $ENV{DBIC_TRACE} = 0 }
+
use Test::More;
use Test::Warn;
+use Test::Exception;
use DBIx::Class::Carp;
use lib 't/lib';
use DBICTest;
-warnings_exist {
- DBIx::Class::frobnicate();
-} [
- qr/carp1/,
- qr/carp2/,
-], 'expected warnings from carp_once';
+{
+ sub DBICTest::DBICCarp::frobnicate {
+ DBICTest::DBICCarp::branch1();
+ DBICTest::DBICCarp::branch2();
+ }
-done_testing;
+ sub DBICTest::DBICCarp::branch1 { carp_once 'carp1' }
+ sub DBICTest::DBICCarp::branch2 { carp_once 'carp2' }
+
+
+ warnings_exist {
+ DBICTest::DBICCarp::frobnicate();
+ } [
+ qr/carp1/,
+ qr/carp2/,
+ ], 'expected warnings from carp_once';
+}
+
+{
+ {
+ package DBICTest::DBICCarp::Exempt;
+ use DBIx::Class::Carp;
-sub DBIx::Class::frobnicate {
- DBIx::Class::branch1();
- DBIx::Class::branch2();
+ sub _skip_namespace_frames { qr/^DBICTest::DBICCarp::Exempt/ }
+
+ sub thrower {
+ sub {
+ DBICTest->init_schema(no_deploy => 1)->throw_exception('time to die');
+ }->();
+ }
+
+ sub dcaller {
+ sub {
+ thrower();
+ }->();
+ }
+
+ sub warner {
+ eval {
+ sub {
+ eval {
+ carp ('time to warn')
+ }
+ }->()
+ }
+ }
+
+ sub wcaller {
+ warner();
+ }
+ }
+
+ # the __LINE__ relationship below is important - do not reformat
+ throws_ok { DBICTest::DBICCarp::Exempt::dcaller() }
+ qr/\QDBICTest::DBICCarp::Exempt::thrower(): time to die at @{[ __FILE__ ]} line @{[ __LINE__ - 1 ]}\E$/,
+ 'Expected exception callsite and originator'
+ ;
+
+ # the __LINE__ relationship below is important - do not reformat
+ warnings_like { DBICTest::DBICCarp::Exempt::wcaller() }
+ qr/\QDBICTest::DBICCarp::Exempt::warner(): time to warn at @{[ __FILE__ ]} line @{[ __LINE__ - 1 ]}\E$/,
+ ;
}
-sub DBIx::Class::branch1 { carp_once 'carp1' }
-sub DBIx::Class::branch2 { carp_once 'carp2' }
+done_testing;
warnings_exist {
$artist_rs->find({})
-} qr/\QDBIx::Class::ResultSet::find(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single/
+} qr/\QQuery returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single/
=> "Non-unique find generated a cursor inexhaustion warning";
throws_ok {