[Python-Dev] request._parse

Terry Reedy tjreedy at udel.edu
Sat Feb 23 22:50:16 CET 2013


On 2/23/2013 2:36 PM, Demian Brecht wrote:
> Hope this question belongs here and not in python-ideas, but I'm
> curious about _parse in the Request object. Specifically, why it was
> decided to write a custom parse function when the likes or urlparse or
> urlsplit do essentially the same thing.

urllib.parse contains urlparse, urlsplit, splittype, splithost, and 
other utility functions. urllib.request imports many, including those 
four. Request._parse sequentially uses splittype and splithost, raising 
if splittype fails. So it seems to me that it does both less and more 
that the more general functions. Since urlparse is used four other 
places in the module and urlsplit once, I would start with the 
assumption that either would have been here if it were the best and easiest.

 > Doesn't really seem DRY to me.

Nearly all the work in _parse is done by splittype, splithost, and 
unquote, which *is* DRY as far as this function is concerned. The rest 
of the code is assignment, two ifs, and a raise.

If you want to be helpful, leave _parse along and find a real bug to 
work on ;-). There are several urllib bug issues. Or check out the code 
coverage of some test module (see devguide), and see if more tests are 
needed.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list