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
upgrade to HTML::TreeBuilder 5 to get weak references #262
Conversation
This might break people's code on really old Perls. Closes libwww-perl#251
Pull Request Test Coverage Report for Build 223
💛 - Coveralls |
@@ -834,13 +834,16 @@ sub text { | |||
my $self = shift; | |||
|
|||
if ( not defined $self->{text} ) { | |||
require HTML::TreeBuilder; | |||
unless ( exists $INC{'HTML::TreeBuilder'} ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you skip checking version and importing -weak
if exists $INC{'HTML::TreeBuilder'}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am checking the version, but it has to be done after the require
call. It's easy to do it with use
, but the code we have here explicitly loads the module at run-time. In the require
perldoc it explains
If the VERSION argument is present between Module and LIST, then the use will call the VERSION method in class Module with the given version as an argument:
use Module 12.34;
is equivalent to:
BEGIN { require Module; Module->VERSION(12.34) }
I put the %INC
lookup in because without it, it will do the version check and import
call every single time this method is called. I would have liked to tie it to require
, but it always returns true even if the module has already been loaded. Under the hood it also checks in %INC
as far as I understand, so doing that myself before attempting the version check and import
seemed like the right thing to do.
I'm happy to add a test that proves this works.
Could you elaborate? |
Sure. In https://metacpan.org/pod/HTML::Element#Weak-References it says
I merely paraphrased this. 5.6.0 is Old of course, and I did not check if Mech can work there at all. But I thought I'd at least mention it in the commit. I did change the minimum version of Scalar::List::Util from any to the earliest that brings Anyway, I believe we are not going to seriously break anyone's code. It is just a backwards compatibility change that should probably be mentioned. |
It's also interesting that the travis builds failed because of perltidy. What happened there? |
We need to add a test dep on |
Thanks for bringing that up. With this module, I don't think we care about going back that far. With some of the other modules in this org, we might be more conservative, but that's seriously old. |
@skaji are you happy with this pull request? |
@oalders Yes, I am. |
Thanks @simbabque and @skaji! |
This might break people's code on really old Perls.
Closes #251