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-104522: Change message returned by subprocess when cwd option is not the cause#104851

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

Closed
PurityLake wants to merge7 commits intopython:mainfromPurityLake:gh104522-fix

Conversation

@PurityLake
Copy link
Contributor

@PurityLakePurityLake commentedMay 24, 2023
edited by bedevere-bot
Loading

Refers to#104522

Summary of change:
subprocess._execute_child would raise an exception referencingcwd as the cause of the issue even if this not the case.

So in the sample code:

importsubprocesssubprocess.check_call(["pwd"],user="root",cwd="/tmp")# orsubprocess.check_call(["pwd"],pass_fds=[30,],cwd="/tmp")

subprocess will put the blame oncwd but raise the correct exception. This can be misleading to the user as to what the correct cause is.

Current state of this PR,:
The exception type is checked by instantiating an error object store inchild_exception_type which is OSError, but when supplied the errno and any string can be tested withisinstance to check forFileNotFoundError andNotADirectoryError, these exceptions imply thatcwd is most certainly the error as at this point as the subprocess was inpreexec. Although if other errors are raise in this context the errno and message are still raised but contents ofcwd will not be passed the exception.

@serhiy-storchaka
Copy link
Member

Good idea, but not very reliable. Other errno can be set by failingchdir(cwd) (such as EACCES or ELOOP), and we cannot guarantee that ENOENT and ENOTDIR can only be set by this call. I implemented more reliable way in#114195.

gpshead reacted with thumbs up emoji

@gpshead
Copy link
Member

thanks, Serhiy's other PR has been merged! :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@PurityLake@serhiy-storchaka@gpshead@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp