summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2012-02-07 02:45:19 +0000
committerZefram <zefram@fysh.org>2012-02-07 03:44:49 +0000
commitedda670c3a5d90819e8702dc489d4806d1ab850f (patch)
treee04ff305d74077986e4304f4ff3aace0df08bad0 /dist
parent9d0e037af4f0a038f7bbf0381454a64ddde8fa54 (diff)
downloadperl-edda670c3a5d90819e8702dc489d4806d1ab850f.tar.gz
in Carp, fix circular dep on Perl 5.6
The circular dependency between Carp and warnings was causing trouble with new versions of Carp against very old versions of warnings (versions that were bundled with Perl 5.6). No functional effect on blead.
Diffstat (limited to 'dist')
-rw-r--r--dist/Carp/lib/Carp.pm11
-rw-r--r--dist/Carp/t/with_warnings.t9
2 files changed, 20 insertions, 0 deletions
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index f6ce347d57..e7c4694278 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -402,6 +402,17 @@ sub trusts_directly {
: @{"$class\::ISA"};
}
+if(!defined($warnings::VERSION) || $warnings::VERSION < 1.03) {
+ # Very old versions of warnings.pm import from Carp. This can go
+ # wrong due to the circular dependency. If Carp is invoked before
+ # warnings, then Carp starts by loading warnings, then warnings
+ # tries to import from Carp, and gets nothing because Carp is in
+ # the process of loading and hasn't defined its import method yet.
+ # So we work around that by manually exporting to warnings here.
+ no strict "refs";
+ *{"warnings::$_"} = \&$_ foreach @EXPORT;
+}
+
1;
__END__
diff --git a/dist/Carp/t/with_warnings.t b/dist/Carp/t/with_warnings.t
new file mode 100644
index 0000000000..2ed9b14b35
--- /dev/null
+++ b/dist/Carp/t/with_warnings.t
@@ -0,0 +1,9 @@
+BEGIN { print "1..1\n"; }
+
+use Carp ();
+use warnings ();
+$SIG{__WARN__} = sub {};
+eval { warnings::warn("syntax", "foo") };
+print $@ eq "" ? "" : "not ", "ok 1\n";
+
+1;