New submission from Chad Birch: I'm not sure if this is something that needs adjustment, but it seems somewhat inconsistent to me.
After using urlparse() on various urls with invalid port values, trying to access .port on the result will raise a ValueError. This case includes urls such as: "http://www.example.com:asdf" "http://www.example.com:1.5" "http://www.example.com:" However, as of May 24 2012 (http://hg.python.org/cpython/diff/d769e64aed79/Lib/urllib/parse.py), if the invalid port value is an integer, accessing .port will result in None. So this includes urls such as: "http://www.example.com:66000" "http://www.example.com:-1" Should these two cases be made consistent, so that either .port is always None or always results in a ValueError if the port section of the url is invalid? I'd be happy to write a patch for it if it's wanted, but I thought I'd check first (and see which of the two options would be correct, if so). ---------- components: Library (Lib) messages: 206881 nosy: chad.birch priority: normal severity: normal status: open title: Inconsistent urlparse/urllib.parse handling of invalid port values? type: behavior _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20059> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com