Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in import() behaviour for Perl > 5.39.1 #168

Merged
merged 1 commit into from
Mar 10, 2024

Conversation

zmughal
Copy link
Contributor

@zmughal zmughal commented Mar 2, 2024

Fixes #167.

See also Perl/perl5#21269.

@zmughal
Copy link
Contributor Author

zmughal commented Mar 2, 2024

To test this:

docker run -v $PWD:/work -w /work --rm -it perl:5.39.1 \
	bash -c '
		curl -fsSL https://raw.githubusercontent.com/skaji/cpm/main/cpm | perl - install -g App::cpm;
		cpm install -g Module::Install::AuthorTests Module::Install::DOAPChangeSets Module::Signature;
		cpanm -nq --showdeps . | xargs cpm install -g ;
		cpanm --verbose --test-only .;
		bash '

Copy link
Contributor

@kjetilk kjetilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm baffled that this would break, but then, given that the test suite passes all the way back to 5.14, there seems to be no harm to merging it.

@kasei
Copy link
Owner

kasei commented Mar 8, 2024

Is there an explanation for what the underlying issue here is? The linked Perl issue left things unclear to me. This particular change seems fine (since, as @kjetilk mentions, the tests still pass). But the overall trend of having to remove constructs like this seems contrary to the API design, and I'd like to understand the implications before changing code.

Move the `Exporter::Tiny` setup before loading anything else so that the
`import()` is visible. Use `require` for `Attean` so that
`Attean->import()` is not called.

Fixes <kasei#167>.

See also <Perl/perl5#21269>.
@zmughal
Copy link
Contributor Author

zmughal commented Mar 10, 2024

Thanks for reviewing the code @kjetilk and @kasei. Yeah, I didn't fully
understand the change myself. I was trying different ways of getting import()
into the package… but it looks like I get it now.

After inspecting the output of Devel::TraceUse, I think that what was going
on was that Attean.pm was being required by Attean/RDF.pm and this was in
turn loading other packages before the Exporter::Tiny::import() was set up.
So I moved it before that and changed use Attean into require Attean.

It should pass via the Docker command and the GitHub Actions (once it is
re-run).

@kasei
Copy link
Owner

kasei commented Mar 10, 2024

Great investigative work! And that does provide a good explanation for both the problem and why this is a good fix.

@kasei kasei merged commit 5e28081 into kasei:master Mar 10, 2024
5 of 12 checks passed
@zmughal zmughal deleted the 167-undef-import branch March 10, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempt to call undefined import method with arguments
3 participants