Nick Coghlan <ncogh...@gmail.com> added the comment:

Attached a second version of the patch. Notable features:
- uses a coercion-to-str-and-back strategy (using ascii-strict)
- a significantly more comprehensive pass through the urlparse test suite. I'm 
happy that the test suite mods are complete with this pass.

The actual coercion-to-str technique I used standardises the type consistency 
check for the attributes and also returns a callable that handles the necessary 
coercion of any results. The parsed/split result objects gain encode/decode 
methods to allow that all to be handled polymorphically (although I think the 
decode methods may actually be redundant in practice).

There's a deliberate loophole in the type consistency checking to allow the 
empty string to be type-neutral. Without that, the scheme='' default argument 
to urlsplit and urlparse becomes painful (as do the urljoin shortcuts for base 
or url being the empty string).

Implementing this was night and day when compared to the initial attempt that 
tried to actually manipulate bytes input as bytes. With that patch, it took me 
multiple runs of the test suite to get everything working. This time, the only 
things I had to fix were typos and bugs in the additional test suite 
enhancements. The actual code logic for the type coercions worked first time.

----------
Added file: http://bugs.python.org/file19353/issue9873_coercion_to_str.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9873>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to