Skip to content

regression in URL.build(…,port="")  #883

@commonism

Description

@commonism

Describe the bug

Input filtering for with_port #793 changed the logic to render the URL to compare the port to None.
94b8679#r116844287
as it is possible to create a URL with a port="" via URL.build, this results in urls created with an empty port.

To Reproduce

import yarl
u = yarl.URL.build(scheme="http", host="api.com", port="", path="/v1")
assert str(u) == "http://api.com/v1", str(u)

Expected behavior

Filtering port="" in URL.build.
I'd even prefer to allow "" and convert to None to stay backwards compatible.

Logs/tracebacks

AssertionError: http://api.com:/v1

Python Version

$ python --version
Python 3.10.6

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.0.2

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.9.2

OS

Linux

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions