From: Gurusamy Sarathy Date: Thu, 22 Nov 2001 03:42:58 +0000 (+0000) Subject: local(*CORE::GLOBAL::require) doesn't behave like other overrides X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9f751c0c83936edb2414f3db711d9aed06f58af;p=p5sagit%2Fp5-mst-13.2.git local(*CORE::GLOBAL::require) doesn't behave like other overrides p4raw-id: //depot/perl@13187 --- diff --git a/op.c b/op.c index 6343a03..edd1ad2 100644 --- a/op.c +++ b/op.c @@ -3431,10 +3431,10 @@ Perl_dofile(pTHX_ OP *term) GV *gv; gv = gv_fetchpv("do", FALSE, SVt_PVCV); - if (!(gv && GvIMPORTED_CV(gv))) + if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) gv = gv_fetchpv("CORE::GLOBAL::do", FALSE, SVt_PVCV); - if (gv && GvIMPORTED_CV(gv)) { + if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) { doop = ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED, append_elem(OP_LIST, term, scalar(newUNOP(OP_RV2CV, 0, @@ -5929,8 +5929,11 @@ Perl_ck_glob(pTHX_ OP *o) if ((o->op_flags & OPf_KIDS) && !cLISTOPo->op_first->op_sibling) append_elem(OP_GLOB, o, newDEFSVOP()); - if (!((gv = gv_fetchpv("glob", FALSE, SVt_PVCV)) && GvIMPORTED_CV(gv))) + if (!((gv = gv_fetchpv("glob", FALSE, SVt_PVCV)) + && GvCVu(gv) && GvIMPORTED_CV(gv))) + { gv = gv_fetchpv("CORE::GLOBAL::glob", FALSE, SVt_PVCV); + } #if !defined(PERL_EXTERNAL_GLOB) /* XXX this can be tightened up and made more failsafe. */ @@ -5948,7 +5951,7 @@ Perl_ck_glob(pTHX_ OP *o) } #endif /* PERL_EXTERNAL_GLOB */ - if (gv && GvIMPORTED_CV(gv)) { + if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) { append_elem(OP_GLOB, o, newSVOP(OP_CONST, 0, newSViv(PL_glob_index++))); o->op_type = OP_LIST; @@ -6259,10 +6262,10 @@ Perl_ck_require(pTHX_ OP *o) /* handle override, if any */ gv = gv_fetchpv("require", FALSE, SVt_PVCV); - if (!(gv && GvIMPORTED_CV(gv))) + if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) gv = gv_fetchpv("CORE::GLOBAL::require", FALSE, SVt_PVCV); - if (gv && GvIMPORTED_CV(gv)) { + if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) { OP *kid = cUNOPo->op_first; cUNOPo->op_first = 0; op_free(o); diff --git a/t/op/override.t b/t/op/override.t index db94ed0..590fcaa 100755 --- a/t/op/override.t +++ b/t/op/override.t @@ -6,7 +6,7 @@ BEGIN { push @INC, '../lib'; } -print "1..10\n"; +print "1..11\n"; # # This file tries to test builtin override using CORE::GLOBAL @@ -61,3 +61,12 @@ print "ok 9\n"; eval "use 5.6"; print "not " unless $r eq "5.6"; print "ok 10\n"; + +# localizing *CORE::GLOBAL::foo should revert to finding CORE::foo +{ + local(*CORE::GLOBAL::require); + $r = ''; + eval "require NoNeXiSt;"; + print "not " if $r or $@ !~ /^Can't locate NoNeXiSt/i; + print "ok 11\n"; +}