From: Steve Peters Date: Tue, 3 Jan 2006 14:58:21 +0000 (+0000) Subject: Bad symbols that are pretending to be dirhandles, should say they X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b5be85c6c6a87e2cf6fc80a9ccc8056a4d1bbf9;p=p5sagit%2Fp5-mst-13.2.git Bad symbols that are pretending to be dirhandles, should say they are dirhandles in their error messages. p4raw-id: //depot/perl@26602 --- diff --git a/gv.c b/gv.c index d960c66..06982bd 100644 --- a/gv.c +++ b/gv.c @@ -73,8 +73,21 @@ Perl_gv_HVadd(pTHX_ register GV *gv) GV * Perl_gv_IOadd(pTHX_ register GV *gv) { - if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) - Perl_croak(aTHX_ "Bad symbol for filehandle"); + if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) { + + /* + * if it walks like a dirhandle, then let's assume that + * this is a dirhandle. + */ + const char *fh = PL_op->op_type == OP_READDIR || + PL_op->op_type == OP_TELLDIR || + PL_op->op_type == OP_SEEKDIR || + PL_op->op_type == OP_REWINDDIR || + PL_op->op_type == OP_CLOSEDIR ? + "dirhandle" : "filehandle"; + Perl_croak(aTHX_ "Bad symbol for %s", fh); + } + if (!GvIOp(gv)) { #ifdef GV_UNIQUE_CHECK if (GvUNIQUE(gv)) {