Changed behavior in urllib.parse.urlunparse

Hi there,

I noticed a change in the behavior of urllib.parse.urlunparse that was introduced in 3.12.6. The change is only apparent in an unrealistic corner case.

Imagine this code snippet

from urllib.parse import urlunparse
print(urlunparse(("https", "", "path", "", "", "")))

If you ignore for a second that netloc is an empty string, the expected output would be https:///path. And that is the output up until 3.12.5.

But in 3.12.6 the output becomes https:path.

I’m now wondering, whether that observation is a result of an intentional change or whether it’s worth reporting a bug. I’d appreciate opinions :slight_smile:

Thank you

The change was specifically made to preserve the relative path in the URL without netloc:

1 Like

@blhsing Thank you for the pointer/answer.

1 Like