From 38311155f8bfb2ee335d4ac122ad148c83ea252e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 4 Jan 2012 18:41:14 -0600 Subject: make this fix more general --- lib/circular/require.pm | 9 ++++----- t/eval.t | 11 +++++++++++ t/eval/Bar.pm | 6 ++++++ t/eval/Foo.pm | 3 +++ 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 t/eval.t create mode 100644 t/eval/Bar.pm create mode 100644 t/eval/Foo.pm diff --git a/lib/circular/require.pm b/lib/circular/require.pm index 6a92b7b..3c65846 100644 --- a/lib/circular/require.pm +++ b/lib/circular/require.pm @@ -75,12 +75,11 @@ sub _require { local $loaded_from{$string_file} = $previous_file; local $previous_file = $string_file; my $ret; - # XXX ugh, base.pm checks against the regex + # ugh, base.pm checks against the regex # /^Can't locate .*? at \(eval / to see if it should suppress the error - # but we're not in an eval anymore... fake it for now, but this will - # definitely break if some other module that overrides CORE::require tries - # to do the same thing - if (caller eq 'base') { + # but we're not in an eval anymore + # fake it up so that this looks the same + if (defined((caller(1))[6])) { my $mod = _pm2mod($file); $ret = $saved_require_hook ? $saved_require_hook->($file) diff --git a/t/eval.t b/t/eval.t new file mode 100644 index 0000000..d9ce952 --- /dev/null +++ b/t/eval.t @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib 't/eval'; +use Test::More; + +no circular::require; + +use_ok('Foo'); + +done_testing; diff --git a/t/eval/Bar.pm b/t/eval/Bar.pm new file mode 100644 index 0000000..10b8543 --- /dev/null +++ b/t/eval/Bar.pm @@ -0,0 +1,6 @@ +package Bar; +sub import { + eval "require Baz"; + die $@ unless $@ =~ /\(eval /; +} +1; diff --git a/t/eval/Foo.pm b/t/eval/Foo.pm new file mode 100644 index 0000000..1558402 --- /dev/null +++ b/t/eval/Foo.pm @@ -0,0 +1,3 @@ +package Foo; +use Bar; +1; -- cgit v1.2.3-54-g00ecf