Handling failures in make_links_absolute/resolve_base_href

Bug #1729365 reported by Hieu Nguyen on 2017-11-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
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

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
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  Edit
Everyone can see this information.

Other bug subscribers