summaryrefslogtreecommitdiff
path: root/dist/Exporter
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2013-07-18 16:03:19 +1000
committerTony Cook <tony@develop-help.com>2013-07-26 10:59:05 +1000
commitd7d11da6a3137eab7a1218de09cab6f2bbfc85ce (patch)
tree387f01a130665b1dada1ebd1f6f1579fbe723ec4 /dist/Exporter
parent0fe08b2b23c9e50663374a37f787ff18c914b79f (diff)
downloadperl-d7d11da6a3137eab7a1218de09cab6f2bbfc85ce.tar.gz
[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
Diffstat (limited to 'dist/Exporter')
-rw-r--r--dist/Exporter/lib/Exporter/Heavy.pm5
-rw-r--r--dist/Exporter/t/warn.t2
2 files changed, 6 insertions, 1 deletions
diff --git a/dist/Exporter/lib/Exporter/Heavy.pm b/dist/Exporter/lib/Exporter/Heavy.pm
index 724028a2b1..21b67c18c4 100644
--- a/dist/Exporter/lib/Exporter/Heavy.pm
+++ b/dist/Exporter/lib/Exporter/Heavy.pm
@@ -38,8 +38,13 @@ sub _rebuild_cache {
sub heavy_export {
+ # Save the old __WARN__ handler in case it was defined
+ my $oldwarn = $SIG{__WARN__};
+
# First make import warnings look like they're coming from the "use".
local $SIG{__WARN__} = sub {
+ # restore it back so proper stacking occurs
+ local $SIG{__WARN__} = $oldwarn;
my $text = shift;
if ($text =~ s/ at \S*Exporter\S*.pm line \d+.*\n//) {
require Carp;
diff --git a/dist/Exporter/t/warn.t b/dist/Exporter/t/warn.t
index 49a109cec4..30109644b9 100644
--- a/dist/Exporter/t/warn.t
+++ b/dist/Exporter/t/warn.t
@@ -34,6 +34,6 @@ package main;
local $SIG{__WARN__} = sub { push @warn, join "", @_ };
eval { Foo->import(":quux") };
- ok(grep(/"quux" is not defined/, @warn), "# TODO warnings captured");
+ ok(grep(/"quux" is not defined/, @warn), "warnings captured");
}