develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132577] BBC Module::Install broken by0301e899536a22752f40481d8a1d141b7a7dda82

Thread Previous | Thread Next
From:
Zefram
Date:
December 12, 2017 19:13
Subject:
Re: [perl #132577] BBC Module::Install broken by0301e899536a22752f40481d8a1d141b7a7dda82
Message ID:
20171212191336.GA19013@fysh.org
I wrote:
>Module::Install fails one of its tests since core commit
>0301e899536a22752f40481d8a1d141b7a7dda82 "properly define perl_parse()
>return value".

Turns out that Module::Install::DSL has some rather convoluted code in
which an "import" method that runs from a Makefile.PL establishes an INIT
block that will do the real work of Makefile.PL and then performs exit(0).
The behaviour difference that's relevant boils down to:

$ perl5.27.6 -lwe 'print "main program"; INIT { print "init block"; } BEGIN { print "begin block"; exit 0; }'
begin block
init block
$ perl-blead -lwe 'print "main program"; INIT { print "init block"; } BEGIN { print "begin block"; exit 0; }'
begin block
$

That is, after a BEGIN block performs an exit(0), perl used to run
INIT blocks and then exit, but now it exits immediately without running
INIT blocks.  It always used to exit without running INIT blocks upon
an exit with non-zero exit code, or upon an exception.

This situation is not precisely the exit(0) from a CHECK block that was
called out in [perl #2754], and indeed on that ticket it was thought
that exit(0) from BEGIN blocks was operating correctly.  Nevertheless,
for it to execute BEGIN blocks is clearly another form of the same bug
with which that ticket is concerned, and the commit has fixed it.

Module::Install::DSL does have a genuine, if not entirely respectable,
reason for its exit(0).  The essence of this module is that a Makefile.PL
invokes the module and then stops containing Perl code, instead switching
to a DSL to specify attributes of its distro.  The module opens up the
Makefile.PL as a file to read it in and parse this DSL, and uses exit(0)
to prevent Perl's parsing of the top-level Makefile.PL from proceeding
into the DSL code that would constitute syntax errors.

However, as far as I can see there's no need at all for the module to
delay execution of the code it generates by putting it in an INIT block.
If that code is instead executed immediately, by deleting the word "INIT"
to turn it into a bare block, everything works.  With that alteration
to the module, the Module-Install distro passes its test suite.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About