@untitaker what if the input is unicode string? This is how it got me the error:
````
$ git checkout 587ea50559340bde5264d25d76ff36cde78821f7
...
$ python3.3
Python 3.3.2 (default, May 18 2013, 17:07:09)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from werkzeug.urls import uri_to_iri
>>> uri_to_iri('http://localhost:8080/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./werkzeug/urls.py", line 151, in uri_to_iri
    hostname += u':' + port.decode(charset, errors)
AttributeError: 'str' object has no attribute 'decode'
>>>
````