This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan, orsenthil, r.david.murray, zulla
Date 2012-02-17.13:58:31
SpamBayes Score 1.3322676e-15
Marked as misclassified No
Message-id <1329487112.86.0.482323675357.issue14036@psf.upfronthosting.co.za>
In-reply-to
Content
Could you provide some failing examples?

The suggestion also seems to run slightly at odds with itself - in one part, silently replacing an invalid port specification with a different value, in another adding additional validation checks.

Also, rather than hardcoding default port numbers for selected protocols, it would make more sense to just look them up via socket.getservbyname(scheme) (and still return None if the scheme isn't recognised). However, I'll need to think about that one for a while - urlparse is designed to be almost purely a string *parsing* library. Looking up default port numbers if one isn't specified really isn't its job. (For one thing, you'd break the ability to exactly recreate the original URL text from the parsed version).

There should definitely by a try/except around that conversion to int(), though - it's just that I'm not yet sure what an appropriate return value is at that point. The raw port string? None? Should there be a separate "raw_port" descriptor that always returns some kind of string, with the port descriptor promising to always return a valid 16-bit port number or None?
History
Date User Action Args
2012-02-17 13:58:32ncoghlansetrecipients: + ncoghlan, orsenthil, r.david.murray, zulla
2012-02-17 13:58:32ncoghlansetmessageid: <1329487112.86.0.482323675357.issue14036@psf.upfronthosting.co.za>
2012-02-17 13:58:32ncoghlanlinkissue14036 messages
2012-02-17 13:58:31ncoghlancreate