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

GH-85168: Use filesystem encoding when converting to/fromfile URIs#126852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 5 commits intopython:mainfrombarneygale:gh-85168
Nov 19, 2024

Conversation

@barneygale
Copy link
Contributor

@barneygalebarneygale commentedNov 15, 2024
edited by bedevere-appbot
Loading

Adjusturllib.request.url2pathname() andpathname2url() to use the filesystem encoding when quoting and unquoting file URIs, rather than forcing use of UTF-8.

No changes are needed in thenturl2path module because Windows always uses UTF-8, per PEP 529.

…` URIsAdjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.
@barneygale
Copy link
ContributorAuthor

barneygale commentedNov 15, 2024
edited
Loading

Thefreedesktop file URI spec is a useful reference here:

There is no specified encoding for filenames, and although we hope
that eventually all filenames will be encoded in UTF8 we can't rely on
this, because then we would be unable to e.g. rename a file with a
misencoded filename.

Also:

Some current apps generate file URIs by converting the filename from
whatever locale the application runs in to UTF8. This behavior means
that URIs can't be converted to filenames without knowing the
locale of the application that produced them, and that not all valid
filenames can be converted to URIs. Such behavior is not allowed,
and should be changed.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM in general. But we should support URIs containing not quoted non-ASCII characters.

@barneygale
Copy link
ContributorAuthor

Thanks for the review - I've made the changes you suggested

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

You can also usefsdecode(TESTFN_UNDECODABLE) andTESTFN_UNENCODABLE in some tests if you wish.

barneygale reacted with thumbs up emoji
@barneygalebarneygale merged commitc9b399f intopython:mainNov 19, 2024
36 checks passed
@miss-islington-app
Copy link

Thanks@barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 19, 2024
…` URIs (pythonGH-126852)Adjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.(cherry picked from commitc9b399f)Co-authored-by: Barney Gale <barney.gale@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 19, 2024
…` URIs (pythonGH-126852)Adjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.(cherry picked from commitc9b399f)Co-authored-by: Barney Gale <barney.gale@gmail.com>
@bedevere-app
Copy link

GH-127039 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelNov 19, 2024
@bedevere-app
Copy link

GH-127040 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelNov 19, 2024
barneygale added a commit that referenced this pull requestNov 19, 2024
…e` URIs (GH-126852) (#127040)GH-85168: Use filesystem encoding when converting to/from `file` URIs (GH-126852)Adjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.(cherry picked from commitc9b399f)Co-authored-by: Barney Gale <barney.gale@gmail.com>
barneygale added a commit that referenced this pull requestNov 20, 2024
…e` URIs (GH-126852) (#127039)GH-85168: Use filesystem encoding when converting to/from `file` URIs (GH-126852)Adjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.(cherry picked from commitc9b399f)Co-authored-by: Barney Gale <barney.gale@gmail.com>
ebonnal pushed a commit to ebonnal/cpython that referenced this pull requestJan 12, 2025
…` URIs (python#126852)Adjust `urllib.request.url2pathname()` and `pathname2url()` to use thefilesystem encoding when quoting and unquoting file URIs, rather thanforcing use of UTF-8.No changes are needed in the `nturl2path` module because Windows alwaysuses UTF-8, per PEP 529.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

+1 more reviewer

@ruidazengruidazengruidazeng approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@barneygale@serhiy-storchaka@ruidazeng

[8]ページ先頭

©2009-2025 Movatter.jp