Devel-Confess
view release on metacpan or search on metacpan
lib/Devel/Confess/_Util.pm view on Meta::CPAN
package Devel::Confess::_Util;
use 5.006;
use strict;
use warnings FATAL => 'all';
no warnings 'once';
use Exporter (); BEGIN { *import = \&Exporter::import }
our @EXPORT = qw(
blessed
refaddr
weaken
longmess
_str_val
_in_END
_can_stringify
_can
_isa
);
use Carp ();
use Carp::Heavy ();
use Scalar::Util qw(blessed refaddr reftype);
# fake weaken if it isn't available. will cause leaks, but this
# is a brute force debugging tool, so we can deal with it.
*weaken = defined &Scalar::Util::weaken
? \&Scalar::Util::weaken
: sub ($) { 0 };
*longmess = !Carp->VERSION ? eval q{
package
Carp;
our (%CarpInternal, %Internal, $CarpLevel);
$CarpInternal{Carp}++;
$CarpInternal{warnings}++;
$Internal{Exporter}++;
$Internal{'Exporter::Heavy'}++;
sub {
my $level = 0;
while (1) {
my $p = (caller($level))[0] || last;
last
unless $CarpInternal{$p} || $Internal{$p};
$level++;
}
local $CarpLevel = $CarpLevel + $level;
no strict 'refs';
local *{"threads::tid"} = \&threads::tid
if defined &threads::tid && !defined &{"threads::tid"};
&longmess;
};
} : eval q{
package
Carp;
sub {
local $INC{'Carp/Heavy.pm'} = $INC{'Carp/Heavy.pm'} || 1;
no strict 'refs';
local *{"threads::tid"} = \&threads::tid
if defined &threads::tid && !defined &{"threads::tid"};
&longmess;
};
} or die $@;
if (defined &Carp::format_arg && $Carp::VERSION < 1.32) {
my $format_arg = \&Carp::format_arg;
eval q{
package
Carp;
our $in_recurse;
$format_arg if 0; # capture
no warnings 'redefine';
sub format_arg {
if (! $in_recurse) {
local $SIG{__DIE__} = sub {};
local $in_recurse = 1;
local $@;
my $arg;
if (
Devel::Confess::_Util::blessed($_[0])
&& eval { $_[0]->can('CARP_TRACE') }
) {
return $_[0]->CARP_TRACE;
}
elsif (
ref $_[0]
and our $RefArgFormatter
( run in 1.526 second using v1.01-cache-2.11-cpan-364913b4093 )