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-96192: fix os.ismount() to use a path that is str or bytes#96194

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
JelleZijlstra merged 3 commits intopython:mainfromcalestyo:fix-path-in-os.ismount
Nov 14, 2022
Merged

gh-96192: fix os.ismount() to use a path that is str or bytes#96194

JelleZijlstra merged 3 commits intopython:mainfromcalestyo:fix-path-in-os.ismount
Nov 14, 2022

Conversation

@calestyo
Copy link
Contributor

@calestyocalestyo commentedAug 23, 2022
edited by bedevere-bot
Loading

Co-authored-by: Eryk Sun <eryksun@gmail.com>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@ghost
Copy link

ghost commentedAug 23, 2022
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@orsenthil
Copy link
Member

Hi@calestyo , Would you like to add a test for this?

@orsenthilorsenthil self-assigned thisAug 24, 2022
@calestyo
Copy link
ContributorAuthor

@orsenthil Well I could at least try, but two issues here:

  • I think it would be handy to have a test that does this forany function that is ought to accept the PathLike-interface, but that in turn doesn't seem to be possibly generically.
  • The test get a bit ugly, since one cannot createos.DirEntry objects, even if I'd just made one foros.ismount(). Right now these do:
    deftest_ismount(self):
    self.assertIs(posixpath.ismount("/"),True)
    self.assertIs(posixpath.ismount(b"/"),True)

but one cannot yield/ asos.DirEntry viascandir().

@orsenthil
Copy link
Member

Without this patch, I would expect this

self.assertIs(posixpath.ismount(b"/"), True)

to fail or behavior differently than with this patch.

What might I be missing?

@calestyo
Copy link
ContributorAuthor

Without this patch, I would expect this

self.assertIs(posixpath.ismount(b"/"), True)

to fail or behavior differently than with this patch.

That I don't understand… as far as I understand it, it should have worked previously with bothstr andbytes but not when e.g. using it with aos.DirEntry.

Copy link
Member

@JelleZijlstraJelleZijlstra left a comment

Choose a reason for hiding this comment

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

Could you add a test that passes a bytes path-like toismount()?

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@JelleZijlstraJelleZijlstra added needs backport to 3.10only security fixes needs backport to 3.11only security fixes labelsOct 7, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
@calestyo
Copy link
ContributorAuthor

Could you add a test that passes a bytes path-like to ismount()?

@orsenthil@JelleZijlstra … I've added a test usingPath. Does that seem ok for you?

@calestyo
Copy link
ContributorAuthor

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@JelleZijlstra: please review the changes made to this pull request.

@JelleZijlstra
Copy link
Member

The tests are failing.

@calestyo
Copy link
ContributorAuthor

Uagh... seemsPath itsellf claims it would accept a PathLike object, e.g.pathlib.PurePath(*pathsegments) says:

Each element of pathsegments can be either a string representing a path segment, an object implementing the os.PathLike interface which returns a string, or another path object:

but it doesn't really, but only such that use strings. Isn't that yet another bug?

Anyway... I don't know how to do a proper test then. Is there any other PathLike object type in the library?

The only I'd know isos.DirEntry which one cannot directly create. I could useos.scandir(b"/")__next__() but there's the result could be a mointpoint or not.

Any ideas?

@calestyo
Copy link
ContributorAuthor

Oh and is a test here really worth it? The fix is trivial, should someone ever remove it, the check could also just be removed by accident as well.

As I've already saidabove, to which noone replied,... it would IMO only make sense, ifall these functions could be tested for whether they accept the right types, at once.

@JelleZijlstra
Copy link
Member

Uagh... seemsPath itsellf claims it would accept a PathLike object, e.g.pathlib.PurePath(*pathsegments) says:

Each element of pathsegments can be either a string representing a path segment, an object implementing the os.PathLike interface which returns a string, or another path object:

but it doesn't really, but only such that use strings. Isn't that yet another bug?

The problem in your test is thatPath only supports str paths, not bytes paths. This is well-established behavior and not a bug.

Anyway... I don't know how to do a proper test then. Is there any other PathLike object type in the library?

You can usetest.support.os_helper.FakePath.

Oh and is a test here really worth it?

Yes, every bugfix needs an associated test.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
@calestyo
Copy link
ContributorAuthor

You can use test.support.os_helper.FakePath.

thx... still fails on one platform though... no idea why

@JelleZijlstra
Copy link
Member

Looks spurious, I retried it.

@JelleZijlstraJelleZijlstra merged commit367f552 intopython:mainNov 14, 2022
@miss-islington
Copy link
Contributor

Thanks@calestyo for the PR, and@JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-99455 is a backport of this pull request to the3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 14, 2022
…ythonGH-96194)(cherry picked from commit367f552)Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>Co-authored-by: Eryk Sun <eryksun@gmail.com>Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelNov 14, 2022
@bedevere-bot
Copy link

GH-99456 is a backport of this pull request to the3.10 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.10only security fixes labelNov 14, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 14, 2022
…ythonGH-96194)(cherry picked from commit367f552)Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>Co-authored-by: Eryk Sun <eryksun@gmail.com>Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
miss-islington added a commit that referenced this pull requestNov 30, 2022
(cherry picked from commit367f552)Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>Co-authored-by: Eryk Sun <eryksun@gmail.com>Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
JelleZijlstra added a commit that referenced this pull requestJan 22, 2023
…H-96194) (#99456)gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194)(cherry picked from commit367f552)Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>Co-authored-by: Eryk Sun <eryksun@gmail.com>Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

Assignees

@orsenthilorsenthil

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@calestyo@bedevere-bot@orsenthil@JelleZijlstra@miss-islington

[8]ページ先頭

©2009-2025 Movatter.jp