diff --git a/Porting/GitUtils.pm b/Porting/GitUtils.pm index f1b4354dfd49c..6377b6b27bb2d 100644 --- a/Porting/GitUtils.pm +++ b/Porting/GitUtils.pm @@ -1,4 +1,5 @@ #!/usr/bin/perl +package GitUtils; use strict; use warnings; use POSIX qw(strftime); diff --git a/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t b/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t index 11fef62febf3a..936d1bf2a2f97 100644 --- a/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t +++ b/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t @@ -1,7 +1,7 @@ use Test2::Tools::Tiny; use Test2::Util qw/get_tid USE_THREADS try ipc_separator/; use File::Temp qw/tempfile/; -use File::Spec qw/catfile/; +use File::Spec; use List::Util qw/shuffle/; use strict; use warnings; diff --git a/gv.c b/gv.c index 1f06833e1a9b6..a5598effe70ba 100644 --- a/gv.c +++ b/gv.c @@ -1149,13 +1149,7 @@ Perl_gv_fetchmethod_pvn_flags(pTHX_ HV *stash, const char *name, const STRLEN le gv = gv_fetchmeth_pvn(stash, name, name_end - name, 0, flags); if (!gv) { - /* This is the special case that exempts Foo->import and - Foo->unimport from being an error even if there's no - import/unimport subroutine */ - if (strEQ(name,"import") || strEQ(name,"unimport")) { - gv = (GV*)sv_2mortal((SV*)newCONSTSUB_flags(NULL, - NULL, 0, 0, NULL)); - } else if (autoload) + if (autoload) gv = gv_autoload_pvn( ostash, name, name_end - name, GV_AUTOLOAD_ISMETHOD|flags ); diff --git a/t/op/universal.t b/t/op/universal.t index 4c277c3e39c09..108108a5f583b 100644 --- a/t/op/universal.t +++ b/t/op/universal.t @@ -139,9 +139,9 @@ like $@, qr/^Invalid version format/; my $subs = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::; if ('a' lt 'A') { - is $subs, "can isa DOES VERSION"; + is $subs, "can import isa unimport DOES VERSION"; } else { - is $subs, "DOES VERSION can isa"; + is $subs, "DOES VERSION can import isa unimport"; } ok $a->isa("UNIVERSAL"); @@ -160,11 +160,10 @@ eval "use UNIVERSAL"; ok $a->isa("UNIVERSAL"); my $sub2 = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::; -# XXX import being here is really a bug if ('a' lt 'A') { - is $sub2, "can import isa DOES VERSION"; + is $sub2, "can import isa unimport DOES VERSION"; } else { - is $sub2, "DOES VERSION can import isa"; + is $sub2, "DOES VERSION can import isa unimport"; } eval 'sub UNIVERSAL::sleep {}'; diff --git a/universal.c b/universal.c index 955850431732c..58db8d0ce151f 100644 --- a/universal.c +++ b/universal.c @@ -434,6 +434,23 @@ XS(XS_UNIVERSAL_isa) } } +XS(XS_UNIVERSAL_import_unimport); /* prototype to pass -Wmissing-prototypes */ +XS(XS_UNIVERSAL_import_unimport) +{ + dXSARGS; + dXSI32; + + if (items > 1) { + char *class_pv= SvPV_nolen(ST(0)); + /* _charnames is special - ignore it for now */ + if (strNE(class_pv,"_charnames")) + croak("Attempt to call UNIVERSAL::%s() with arguments via package %s (Perhaps you forgot to load \"%s\"?)", + ix ? "unimport" : "import", class_pv, class_pv); + } + XSRETURN_EMPTY; +} + + XS(XS_UNIVERSAL_can); /* prototype to pass -Wmissing-prototypes */ XS(XS_UNIVERSAL_can) { @@ -1253,6 +1270,8 @@ static const struct xsub_details these_details[] = { {"UNIVERSAL::isa", XS_UNIVERSAL_isa, NULL, 0 }, {"UNIVERSAL::can", XS_UNIVERSAL_can, NULL, 0 }, {"UNIVERSAL::DOES", XS_UNIVERSAL_DOES, NULL, 0 }, + {"UNIVERSAL::import", XS_UNIVERSAL_import_unimport, NULL, 0}, + {"UNIVERSAL::unimport", XS_UNIVERSAL_import_unimport, NULL, 1}, #define VXS_XSUB_DETAILS #include "vxs.inc" #undef VXS_XSUB_DETAILS