diff mbox series

[11/15] remote-mediawiki tests: replace deprecated Perl construct

Message ID 20200916102918.29805-12-avarab@gmail.com
State New
Headers show
Series remote-mediawiki: various fixes to make tests pass | expand

Commit Message

Ævar Arnfjörð Bjarmason Sept. 16, 2020, 10:29 a.m. UTC
The use of the encoding pragma has been a hard error since Perl 5.18,
which was released in 2013. What this script really wanted to do was
to decode @ARGV and write out some files with the UTF-8 PerlIO
layer. Let's just do that explicitly instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/mw-to-git/t/test-gitmw.pl | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jeff King Sept. 16, 2020, 6:49 p.m. UTC | #1
On Wed, Sep 16, 2020 at 12:29:14PM +0200, Ævar Arnfjörð Bjarmason wrote:

> The use of the encoding pragma has been a hard error since Perl 5.18,
> which was released in 2013. What this script really wanted to do was
> to decode @ARGV and write out some files with the UTF-8 PerlIO
> layer. Let's just do that explicitly instead.

Makes sense. After reading this, I expected the utf::decode() for argv
you added, but wondered about the UTF-8 output. But I think the "use
open ':encoding(utf8)'" below takes care of that.

-Peff
diff mbox series

Patch

diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
index afc4650b1a..71e5b06235 100755
--- a/contrib/mw-to-git/t/test-gitmw.pl
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -24,7 +24,6 @@ 
 
 use MediaWiki::API;
 use Getopt::Long;
-use encoding 'utf8';
 use DateTime::Format::ISO8601;
 use open ':encoding(utf8)';
 use constant SLASH_REPLACEMENT => "%2F";
@@ -222,4 +221,4 @@  sub wiki_upload_file {
 	getallpagename => \&wiki_getallpagename,
 );
 die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call};
-$functions_to_call{$fct_to_call}->(@ARGV);
+$functions_to_call{$fct_to_call}->(map { utf8::decode($_); $_ } @ARGV);