Michael G. Schwern [Mon, 6 Oct 2003 13:14:36 +0000 (06:14 -0700)]
Message-Id: <
20031006131436.G20960@ttul.org>
p4raw-id: //depot/perl@21418
# Exporter. It's bad enough that all classes have a import() method
# whenever UNIVERSAL.pm is loaded.
require Exporter;
-*import = \&Exporter::import;
@EXPORT_OK = qw(isa can VERSION);
+# Make sure that even though the import method is called, it doesn't do
+# anything unless its called on UNIVERSAL
+sub import {
+ return unless $_[0] eq __PACKAGE__;
+ goto &Exporter::import;
+}
+
1;
__END__
$| = 1;
}
-print "1..100\n";
+print "1..101\n";
$a = {};
bless $a, "Bob";
my $x = {}; bless $x, 'X';
test $x->isa('UNIVERSAL');
test $x->isa('UNIVERSAL');
+
+
+# Check that the "historical accident" of UNIVERSAL having an import()
+# method doesn't effect anyone else.
+eval { Some::Package->import("bar") };
+test !$@;