Normalize urlparse fragment behavior across all supported Python versions

See code comment. This includes the test fix from #684 and an implementation fix for everything else.