-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base.pm broken by CORE::GLOBAL::require #13585
Comments
From zefram@fysh.orgCreated by zefram@fysh.orgIf a CORE::GLOBAL::require is set up to wrap the standard require, if $ perl -lwe 'package Foo::Bar { sub zzz {} } use base "Foo::Bar"; print "OK"' I'd call that require override well-behaved, in the relevant respects. This problem can be avoided by base.pm using "CORE::require" to suppress Module::Runtime suffered the same bug. I fixed it there by using base.pm could perhaps incorporate the same fix, but M:R and base.pm Another option is to drop the part of the error message matching that Perl Info
|
From @tonycozOn Thu Feb 06 15:12:28 2014, zefram@fysh.org wrote:
M::R's functionality would be useful in core, but I'm not sure I'd want to do it now, with 5.20 coming close.
Attached is a patch to do just that. (I have a separate one to bump $base::VERSION) I'll apply this soonish, unless there's an objection. Tony |
From @tonycoz0001-perl-121196-only-examine-the-name-being-included.patchFrom b7426923f255f834dcf35cc83de2eb4c983e3ac0 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 17 Feb 2014 15:19:34 +1100
Subject: [PATCH 1/2] [perl #121196] only examine the name being included
Checking the location called from broke require overrides.
---
MANIFEST | 1 +
dist/base/lib/base.pm | 6 ++----
dist/base/t/core-global.t | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+), 4 deletions(-)
create mode 100644 dist/base/t/core-global.t
diff --git a/MANIFEST b/MANIFEST
index e5dab21..8cee6d3 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2894,6 +2894,7 @@ dist/base/t/base-open-chunk.t See if base works
dist/base/t/base-open-line.t See if base works
dist/base/t/base.t See if base works
dist/base/t/compile-time.t See if base works
+dist/base/t/core-global.t See if base works around CORE::GLOBAL::require
dist/base/t/fields-5_6_0.t See if fields work
dist/base/t/fields-5_8_0.t See if fields work
dist/base/t/fields-base.t See if fields work
diff --git a/dist/base/lib/base.pm b/dist/base/lib/base.pm
index d7ef70a..55d3b47 100644
--- a/dist/base/lib/base.pm
+++ b/dist/base/lib/base.pm
@@ -96,8 +96,6 @@ sub import {
{
local $SIG{__DIE__};
my $fn = _module_to_filename($base);
- my $file = __FILE__;
- my $line = __LINE__ + 1;
eval { require $fn };
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
@@ -107,8 +105,8 @@ sub import {
# probably be using parent.pm, which doesn't try to
# guess whether require is needed or failed,
# see [perl #118561]
- die if $@ && $@ !~ /^Can't locate \Q$fn\E .*? at \Q$file\E line \Q$line\E(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/s
- || $@ =~ /Compilation failed in require at \Q$file\E line \Q$line\E(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/;
+ die if $@ && $@ !~ /^Can't locate \Q$fn\E .*? at .* line [0-9]+(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/s
+ || $@ =~ /Compilation failed in require at .* line [0-9]+(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/;
unless (%{"$base\::"}) {
require Carp;
local $" = " ";
diff --git a/dist/base/t/core-global.t b/dist/base/t/core-global.t
new file mode 100644
index 0000000..a912166
--- /dev/null
+++ b/dist/base/t/core-global.t
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More tests => 1;
+
+BEGIN { *CORE::GLOBAL::require = sub { require $_[0] }; }
+
+{
+ # [perl #121196]
+ {
+ package RequireOverride;
+ sub zzz {}
+ }
+ ok(eval <<'EOS', "handle require overrides")
+package RequireOverrideB;
+use base 'RequireOverride';
+1
+EOS
+ or diag $@;
+}
--
1.7.10.4
|
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Sun Feb 16 20:36:13 2014, tonyc wrote:
Applied as 257518b with a version bump in 6d879f8. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#121196 (status was 'resolved')
Searchable as RT121196$
The text was updated successfully, but these errors were encountered: