1 package # hide from PAUSE
7 use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0);
10 package # hide from pause
18 BROKEN_FORK => ($^O eq 'MSWin32') ? 1 : 0,
20 HAS_ITHREADS => $Config{useithreads} ? 1 : 0,
22 # ::Runmode would only be loaded by DBICTest, which in turn implies t/
23 DBICTEST => eval { DBICTest::RunMode->is_author } ? 1 : 0,
25 # During 5.13 dev cycle HELEMs started to leak on copy
27 # request for all tests would force "non-leaky" illusion and vice-versa
28 defined $ENV{DBICTEST_ALL_LEAKS} ? !$ENV{DBICTEST_ALL_LEAKS}
29 # otherwise confess that this perl is busted ONLY on smokers
30 : eval { DBICTest::RunMode->is_smoker } && ($] >= 5.013005 and $] <= 5.013006) ? 1
31 # otherwise we are good
35 ASSERT_NO_INTERNAL_WANTARRAY => $ENV{DBIC_ASSERT_NO_INTERNAL_WANTARRAY} ? 1 : 0,
37 IV_SIZE => $Config{ivsize},
42 constant->import( OLD_MRO => 1 );
46 constant->import( OLD_MRO => 0 );
51 use Scalar::Util qw(refaddr weaken);
54 our @EXPORT_OK = qw(sigwarn_silencer modver_gt_or_eq fail_on_internal_wantarray);
56 sub sigwarn_silencer {
59 croak "Expecting a regexp" if ref $pattern ne 'Regexp';
61 my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) };
63 return sub { &$orig_sig_warn unless $_[0] =~ $pattern };
69 croak "Nonsensical module name supplied"
70 if ! defined $mod or ! length $mod;
72 croak "Nonsensical minimum version supplied"
73 if ! defined $ver or $ver =~ /[^0-9\.\_]/;
75 local $SIG{__WARN__} = sigwarn_silencer( qr/\Qisn't numeric in subroutine entry/ )
76 if SPURIOUS_VERSION_CHECK_WARNINGS;
79 eval { $mod->VERSION($ver) } ? 1 : 0;
83 my $list_ctx_ok_stack_marker;
85 sub fail_on_internal_wantarray {
86 return if $list_ctx_ok_stack_marker;
88 if (! defined wantarray) {
89 croak('fail_on_internal_wantarray() needs a tempvar to save the stack marker guard');
93 while ( ( (caller($cf+1))[3] || '' ) =~ / :: (?:
95 # these are public API parts that alter behavior on wantarray
96 search | search_related | slice | search_literal
100 # these are explicitly prefixed, since we only recognize them as valid
101 # escapes when they come from the guts of CDBICompat
102 CDBICompat .*? :: (?: search_where | retrieve_from_sql | retrieve_all )
109 (caller($cf))[0] =~ /^(?:DBIx::Class|DBICx::)/
113 DBIx::Class::Exception->throw( sprintf (
114 "Improper use of %s(0x%x) instance in list context at %s line %d\n\n\tStacktrace starts",
115 ref($obj), refaddr($obj), (caller($cf))[1,2]
116 ), 'with_stacktrace');
120 weaken ( $list_ctx_ok_stack_marker = $mark );