[New-bugs-announce] [issue2987] RFC2732 support for urlparse (e.g. http://[::1]:80/)

Hans Ulrich Niedermann report at bugs.python.org
Tue May 27 22:40:37 CEST 2008

New submission from Hans Ulrich Niedermann <hun at n-dimensional.de>:

The urlparse module's ways of splitting the location into hostname and
port breaks with RFC2732 style URIs with IPv6 addresses in them:

>>> import urlparse
>>> urlparse.urlparse('http://[::1]:80/').hostname
>>> urlparse.urlparse('http://[::1]:80/').port
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/urlparse.py", line 116, in port
    return int(port, 10)
ValueError: invalid literal for int() with base 10: ':1]:80'

A simple fix is attached, but probably requires a little more thought.

components: Library (Lib)
files: python-urlparse-rfc2732-fix.patch
keywords: patch
messages: 67430
nosy: ndim
severity: normal
status: open
title: RFC2732 support for urlparse (e.g. http://[::1]:80/)
type: feature request
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file10451/python-urlparse-rfc2732-fix.patch

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list