In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/edda670c3a5d90819e8702dc489d4806d1ab850f?hp=9d0e037af4f0a038f7bbf0381454a64ddde8fa54>

- Log -----------------------------------------------------------------
commit edda670c3a5d90819e8702dc489d4806d1ab850f
Author: Zefram <zef...@fysh.org>
Date:   Tue Feb 7 02:45:19 2012 +0000

    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.
-----------------------------------------------------------------------

Summary of changes:
 MANIFEST                    |    1 +
 dist/Carp/lib/Carp.pm       |   11 +++++++++++
 dist/Carp/t/with_warnings.t |    9 +++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 dist/Carp/t/with_warnings.t

diff --git a/MANIFEST b/MANIFEST
index cddf20a..187addc 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3053,6 +3053,7 @@ dist/Carp/t/heavy.t               See if Carp::Heavy works
 dist/Carp/t/swash.t            See if Carp avoids breaking swash loading
 dist/Carp/t/vivify_gv.t                See if Carp leaves utf8:: stuff alone
 dist/Carp/t/vivify_stash.t             See if Carp leaves utf8:: stash alone
+dist/Carp/t/with_warnings.t            See if Carp plays nicely with warnings
 dist/constant/lib/constant.pm  For "use constant"
 dist/constant/t/constant.t     See if compile-time constants work
 dist/constant/t/utf8.t         Test Unicode constants under utf8 pragma
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index f6ce347..e7c4694 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 0000000..2ed9b14
--- /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;

--
Perl5 Master Repository

Reply via email to