In perl.git, the branch abigail/deprecation has been updated <http://perl5.git.perl.org/perl.git/commitdiff/2820dd91910f553dd43a73e9804d9f5213cad9cb?hp=a9cc9addf6d522d6d8435b2bf2ebe9b2d0e36cec>
- Log ----------------------------------------------------------------- commit 2820dd91910f553dd43a73e9804d9f5213cad9cb Author: Abigail <[email protected]> Date: Thu Nov 17 19:34:37 2016 +0100 Opening a file and dir using the same symbol will be fatal in 5.28. Perl 5.10 deprecated using the same symbol to open both a filehandle and a dirhandle, as this can lead to confusing code. In Pelr 5.28, this will become a fatal error. This patch changes the warning to reflect this. ----------------------------------------------------------------------- Summary of changes: pod/perldeprecation.pod | 12 ++++++++++++ pod/perldiag.pod | 10 ++++++---- pp_sys.c | 4 ++-- t/lib/warnings/pp_sys | 16 ++++++++-------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/pod/perldeprecation.pod b/pod/perldeprecation.pod index 1cdca1b..027010d 100644 --- a/pod/perldeprecation.pod +++ b/pod/perldeprecation.pod @@ -45,6 +45,18 @@ removing them from your code fixes the deprecation warning; and removing them will not influence the behaviour of your code. +=head3 Using the same symbol to open a filehandle and a dirhandle + +It used to be legal to use C<open()> to associate both a +filehandle and a dirhandle to the same symbol (glob or scalar). +This idiom is likely to be confusing, and it was deprecated in +Perl 5.10. + +Using the same symbol to C<open()> a filehandle and a dirhandle +will be a fatal error in Perl 5.28. + +You should be using two different symbols instead. + =head3 ${^ENCODING} is no longer supported. The special variable C<${^ENCODING}> was used to implement diff --git a/pod/perldiag.pod b/pod/perldiag.pod index fb4d3dc..52743e3 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4250,19 +4250,21 @@ that isn't open. Check your control flow. See also L<perlfunc/-X>. (S internal) An internal warning that the grammar is screwed up. -=item Opening dirhandle %s also as a file +=item Opening dirhandle %s also as a file. This will be a fatal error in Perl 5.28 (D io, deprecated) You used open() to associate a filehandle to a symbol (glob or scalar) that already holds a dirhandle. Although legal, this idiom might render your code confusing -and is deprecated. +and this was deprecated in Perl 5.10. In Perl 5.28, this +will be a fatal error. -=item Opening filehandle %s also as a directory +=item Opening filehandle %s also as a directory. This will be a fatal error in Perl 5.28 (D io, deprecated) You used opendir() to associate a dirhandle to a symbol (glob or scalar) that already holds a filehandle. Although legal, this idiom might render your code confusing -and is deprecated. +and this was deprecated in Perl 5.10. In Perl 5.28, this +will be a fatal error. =item Operand with no preceding operator in regex; marked by S<<-- HERE> in m/%s/ diff --git a/pp_sys.c b/pp_sys.c index 1e1b459..82d0717 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -630,7 +630,7 @@ PP(pp_open) if (IoDIRP(io)) Perl_ck_warner_d(aTHX_ packWARN2(WARN_IO, WARN_DEPRECATED), - "Opening dirhandle %"HEKf" also as a file", + "Opening dirhandle %"HEKf" also as a file. This will be a fatal error in Perl 5.28", HEKfARG(GvENAME_HEK(gv))); mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); @@ -4008,7 +4008,7 @@ PP(pp_open_dir) if ((IoIFP(io) || IoOFP(io))) Perl_ck_warner_d(aTHX_ packWARN2(WARN_IO, WARN_DEPRECATED), - "Opening filehandle %"HEKf" also as a directory", + "Opening filehandle %"HEKf" also as a directory. This will be a fatal error in Perl 5.28", HEKfARG(GvENAME_HEK(gv)) ); if (IoDIRP(io)) PerlDir_close(IoDIRP(io)); diff --git a/t/lib/warnings/pp_sys b/t/lib/warnings/pp_sys index b1451b1..cf0998d 100644 --- a/t/lib/warnings/pp_sys +++ b/t/lib/warnings/pp_sys @@ -771,8 +771,8 @@ no warnings qw(io deprecated); open FOO, "../harness"; open $foo, "../harness"; EXPECT -Opening dirhandle FOO also as a file at - line 5. -Opening dirhandle $foo also as a file at - line 6. +Opening dirhandle FOO also as a file. This will be a fatal error in Perl 5.28 at - line 5. +Opening dirhandle $foo also as a file. This will be a fatal error in Perl 5.28 at - line 6. ######## # pp_sys.c [pp_open] @@ -787,8 +787,8 @@ no warnings qw(io deprecated); open FOO, "../harness"; open $ï½ï½ï½, "../harness"; EXPECT -Opening dirhandle FOO also as a file at - line 8. -Opening dirhandle $ï½ï½ï½ also as a file at - line 9. +Opening dirhandle FOO also as a file. This will be a fatal error in Perl 5.28 at - line 8. +Opening dirhandle $ï½ï½ï½ also as a file. This will be a fatal error in Perl 5.28 at - line 9. ######## # pp_sys.c [pp_open_dir] use warnings; @@ -800,8 +800,8 @@ no warnings qw(io deprecated); opendir FOO, "."; opendir $foo, "."; EXPECT -Opening filehandle FOO also as a directory at - line 5. -Opening filehandle $foo also as a directory at - line 6. +Opening filehandle FOO also as a directory. This will be a fatal error in Perl 5.28 at - line 5. +Opening filehandle $foo also as a directory. This will be a fatal error in Perl 5.28 at - line 6. ######## # pp_sys.c [pp_open_dir] @@ -817,8 +817,8 @@ no warnings qw(io deprecated); opendir FOO, "."; opendir $ï½ï½ï½, "."; EXPECT -Opening filehandle FOO also as a directory at - line 9. -Opening filehandle $ï½ï½ï½ also as a directory at - line 10. +Opening filehandle FOO also as a directory. This will be a fatal error in Perl 5.28 at - line 9. +Opening filehandle $ï½ï½ï½ also as a directory. This will be a fatal error in Perl 5.28 at - line 10. ######## # pp_sys.c [pp_*dir] use Config ; -- Perl5 Master Repository
