Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

urllib.request.pathname2url() and url2pathname() remove slashes on Windows #126212

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error
@barneygale

Description

@barneygale

Bug report

Bug description:

urllib.request.pathname2url() unexpectedly removes doubled and trailing slashes, but only on Windows, and only for DOS device paths (not UNC paths):

>>>fromurllib.requestimportpathname2url,url2pathname>>>pathname2url('C:\\')'///C:'# This is *not* the same path!>>>pathname2url('C:\\foo\\')'///C:/foo'>>>pathname2url('C:\\foo\\\\bar')'///C:/foo/bar'

url2pathname() does almost the same thing, except that it specially preserves a slash immediately after a DOS drive (but not elsewhere):

>>>url2pathname('///c:/')'C:\\'# OK>>>url2pathname('///c:/foo/')'C:\\foo'>>>url2pathname('///c:/foo//bar')'C:\\foo\\bar'

This behaviour makes no sense and has no equivalent on POSIX, where all slashes are preserved.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp