URI should support copy

Bug #260555 reported by Curtis Hovey
0
Affects Status Importance Assigned to Milestone
lazr.uri
Triaged
Low
Unassigned

Bug Description

I have seen several example in our code where a URI is converted to a string, then used to make a new URL without take advantage of the URI's safety. The problem stems in that the code does not want to alter the URI. The code wants to do something like this:

    return str(URI(self.base_uri).append(key))

I propose that URI() can accept an instance of itself and it will copy the instance attributes. If we change URI.__init__() from:

        if uri is not None:

to

        if uri is not None and isinstance(uri, self.__class__):
            self.scheme = uri.scheme
            self.userinfo = uri.userinfo
            self.host = uri.host
            self.port = uri.port
            self.path = uri.path
            self.query = uri.query
            self.fragment = uri.fragment
        elif uri is not None:

It will support copy.

Curtis Hovey (sinzui)
Changed in launchpad:
status: New → Triaged
Curtis Hovey (sinzui)
affects: launchpad-foundations → lazr.uri
Changed in lazr.uri:
importance: Undecided → Low
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.