Skip to content

Spam #152999

Description

@zamorafer2917-art

require_scheme describes whether the input URL has a file: prefix, not whether the output keeps one. The result is a filesystem path and never contains file:.

With require_scheme=False (the default) the function prepends file: itself (Lib/urllib/request.py), so a URL that already has the scheme becomes file:file:///..., which is your second result.

Correct usage, both returning 'C:\\Program Files':

url2pathname('file:///C:/Program%20Files', require_scheme=True)  # input has the scheme
url2pathname('/C:/Program%20Files')                             # input omits it (default)

So this is working as documented, not a bug.

Originally posted by @tonghuaroot in #152923

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions