Handling failures in make_links_absolute/resolve_base_href

Bug #1729365 reported by Hieu Nguyen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Confirmed
Low
Unassigned

Bug Description

Python : sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)
lxml.etree : (4, 1, 0, 0)
libxml used : (2, 9, 5)
libxml compiled : (2, 9, 5)
libxslt used : (1, 1, 30)
libxslt compiled : (1, 1, 30)

In file 'lxml/html/__init__.py', within 'make_links_absolute' method:
    def make_links_absolute(self, base_url=None, resolve_base_href=True,
                            handle_failures=None):
        ...
        if resolve_base_href:
            self.resolve_base_href()
        ...

I think it should be:

        if resolve_base_href:
            self.resolve_base_href(handle_failures=handle_failures)

Otherwise, calling 'make_links_absolute(..., handle_failures='ingore')' may still raise an exception, because 'resolve_base_href' calls:
        self.make_links_absolute(base_href, resolve_base_href=False,
                                 handle_failures=handle_failures)
at the end.

Regards,
Hieu

Revision history for this message
scoder (scoder) wrote :

Yes, that looks more correct. Care to send a pull request (with tests)?

Changed in lxml:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Hieu Nguyen (hieutngn) wrote :

I'm just a hobbyist and I don't write code with tests. So I will pass :P

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.