develooper Front page | perl.perl5.porters | Postings from February 2011

Re: [rt.cpan.org #65284] Module broken with 5.13.x development perl versions

Thread Previous | Thread Next
From:
Joshua ben Jore
Date:
February 1, 2011 10:13
Subject:
Re: [rt.cpan.org #65284] Module broken with 5.13.x development perl versions
Message ID:
AANLkTi=S1nLhyqEyjdY3EwpwUxbt_A--hcNjDbqH3Kfa@mail.gmail.com
On Mon, Jan 31, 2011 at 7:24 PM, Joshua ben Jore <twists@gmail.com> wrote:
> On Mon, Jan 31, 2011 at 12:11 PM, David Golden <xdaveg@gmail.com> wrote:
>> It's a bug in base.  It shouldn't set the $VERSION to something that
>> doesn't pass a "lax" version number test.
>>
>> If it *has* to set VERSION for some reason, (and I'm not convinced it
>> should) it should just set it to '0'.
>
> base.pm's documented version number has been '-1, set by base.pm'. Are
> you intending to change that?
>
> from `perldoc base`:
>
>    If $VERSION is not detected even after loading it, <base> will
> define $VERSION
>    in the base package, setting it to the string C<-1, set by base.pm>.
>
> Josh
>

I'd like to share this relevant snippet I've pulled from the DarkPAN
because it's relevant for things that would break if base.pm's API
changed. Further, apropos of just how much pain went into this
paragraph, for reasons I don't quite understand, DynaLoader or Inline
completely fail to signal any error at all if dlload() fails because
there's a version mismatch.

    {
        # Loathe base.pm. It has a "feature" where it'll set $VERSION to
        # '-1, set by base.pm' if the variable isn't already present. Inline
        # is going to expect the version to be '0.00' in this case so I'm
        # changing this so DynaLoader can load the XS portion. The
version number
        # in the generated .so and $VERSION must match.
        #
        # Further... since Inline is just going to use 0.00, I'm going
to make sure that I'm storing that value
        # anyway. Or rather... I think it'll go with whatever version
I tell it as long as I give it a version.
        no strict 'refs';
        no warnings;
        if ( ${"${class}::VERSION"} !~ /^\d+\.\d+\z/ ) {
            ${"${class}::VERSION"} = '0.00';

        }
    }

    # Run the Inline->bind in the package that's getting the code.
There's no other way
    # to change my current package than an eval() so that's why I'm doing eval
    # with "package $class".
    my $compilation_ok = eval <<"Inline";
        package $class;

        # During initial coding I noticed that if \@foo::ISA = qw(
Exporter DynaLoader )
        # and \@boo::ISA = qw( foo Exporter DynaLoader ) that the method call
        # boo::->bootstrap would do zilch. If I just nix this temporarily
        # Inline will fill in the Exporter and DynaLoader for me.
        local \@${class}::ISA;

        # This is the equivalent of "eval_xs(...)".
        Inline->bind(
            C => \$c_src,
            NAME => \$class,
            XSMODE => 1,
            DIRECTORY => '${compilation_dir}',
            CLEAN_AFTER_BUILD => 0,
        );
        return 1;
Inline
    my $compilation_error = $@;

Josh

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