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
Originally posted by @tonghuaroot in #152923