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
[PATCH] base.pm: failures loading modules are ignored when sub-package exists #13043
Comments
From @haargCreated by @haargThis is a bug report for perl from haarg@haarg.org, ----------------------------------------------------------------- When base tries to load a module and finds that it doesn't exist, it The patch is based on the base CPAN 2.18 release from CPAN. Perl Info
|
From @haargsub-package-fix.patchdiff --git i/lib/base.pm w/lib/base.pm
index 19fc845..1d3db87 100644
--- i/lib/base.pm
+++ w/lib/base.pm
@@ -82,7 +82,7 @@ sub import {
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
- unless (%{"$base\::"}) {
+ unless (grep { !/::$/ } keys %{"$base\::"}) {
require Carp;
local $" = " ";
Carp::croak(<<ERROR);
diff --git i/t/base.t w/t/base.t
old mode 100644
new mode 100755
index 6fb24ea..705ed8f
--- i/t/base.t
+++ w/t/base.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 11;
+use Test::More tests => 12;
use_ok('base');
@@ -55,6 +55,11 @@ like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
eval q{use base 'reallyReAlLyNotexists'};
like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
' still empty on 2nd load');
+eval 'sub reallyReAlLyNotexists::Sub::welp { }';
+eval q{use base 'reallyReAlLyNotexists'};
+like( $@, qr/^Base class package "reallyReAlLyNotexists" is empty\./,
+ ' empty even with sub-package existing');
+
{
my $warning;
local $SIG{__WARN__} = sub { $warning = shift };
|
From @jkeenanOn Thu Jun 20 17:26:51 2013, haarg wrote:
Can you elaborate a bit about what those issues would be?
Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @ikegamiFoo/Bar.pm exists and Foo.pm doesn't:
|
From @tonycozOn Thu Jun 20 17:26:51 2013, haarg wrote:
Thanks, applied as c4f21d8. Welcome to the AUTHORS file. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
From @tonycozOn Mon Jun 24 19:08:05 2013, tonyc wrote:
I may need to revert this, based on 118655. The test code in Moose's instance_metaclass_incompat.t has code like: $@ = undef; $@ = undef; $@ = undef; That use base line is causing the test to fail. I think what Moose is doing here is reasonable, so I think the change Tony |
@tonycoz - Status changed from 'resolved' to 'open' |
From @haargI don't really think what Moose is doing here is reasonable. The only reason it worked without this change was the declaration of the I think the test was only working accidentally, and the thing it was I also looked at the other two modules from #118655. One has a bug that |
From @tonycozOn Thu Jun 27 23:04:34 2013, haarg wrote:
I agree about the other two modules, but I still think Moose is being The problem with both the current check and the check your change It's possible for a module to fail to load (due to a syntax error for This problem is one of the reasons parent.pm was created - with I've reverted this change and added a note to base.pm to warn anyone Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
From @haargCan you explain why you think what Moose is going is reasonable? I know this is a heuristic. I prefer to always avoid base.pm in my own "Mentioning a sub-package in the same compile-time context as a later |
From @karenetheridgeOn Tue, Jul 02, 2013 at 06:12:59PM -0700, Tony Cook via RT wrote:
The code in question is: https://github.com/moose/moose/blob/master/t/cmop/instance_metaclass_incompat.t where it's clear that the intent is that the Foo package *does* exist. Is
If it helps the discussion, Moose can quite easily switch from using base
Why is base still in core, anyway? Isn't it past time that we throw it in |
From @rgarciaOn 4 July 2013 00:23, Karen Etheridge <perl@froods.org> wrote:
There are a few core modules that use base. It could be interesting to |
From @dolmenLe Mer. Jul. 03 15:24:35 2013, perl@froods.org a �crit�:
A good reason to switch Moose to parent now is that the patch is already That work is now avalable as a pull request. Olivier Mengué (DOLMEN). |
From @haargSwitching Moose or any core perl modules to use parent instead of base Is there any chance of getting this ticket re-opened? I'd still like The third, Moose, was accidentally relying on some very questionable |
Migrated from rt.perl.org#118561 (status was 'resolved')
Searchable as RT118561$
The text was updated successfully, but these errors were encountered: