[Python-Dev] httplib is not v6 compatible, is this going to be fixed? (original) (raw)

Skip Montanaro skip at pobox.com
Tue Sep 14 19:12:18 CEST 2004


David> Have you actually tested it, cus I made my own fix than was at
David> least and additional 7 lines....

I don't have access to ipv6. I used the ipaddr:port combination in the RedHat bug report as a test input. Here's the change to httplib.py. Replace:

        i = host.find(':')

with

        i = host.rfind(':')

Like I said, it was a one-character fix. rfind() looks from the back of the host/port combination for the colon separating the host and port. Since port numbers can't contain colons, the first colon found from the back has to be the colon separating the host-or-address from the port number.

Here's the change to the test case (Lib/test/test_httplib.py). After the for loop that checks for invalid ports, add this analogous for loop that checks valid host/port combinations:

for hp in ("[fe80::207:e9ff:fe9b]:8000", "www.python.org:80",
           "www.python.org"):
    try:
        h = httplib.HTTP(hp)
    except httplib.InvalidURL:
        print "InvalidURL raised erroneously"

The test case failed before applying the patch and succeeded after. According to the principals of I test-driven development, I'm done until another bug surfaces. In short, I've done what I can to fix the obvious problem. Drilling down any deeper than that is impossible for me. As I indicated, I have no ipv6 access.

If you test it out and still find problems, please submit a bug report on SF. Please don't follow up to python-dev. It's not the appropriate place to discuss the ins and outs of specific patches. I only did so because that was the easiest way to tell the other developers that I'd applied a fix for the problem.

back-to-my-paying-job-ly, y'rs,

Skip



More information about the Python-Dev mailing list