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

Commit7d7c91a

Browse files
authored
bpo-45582: Add a NOT operator to the condition in getpath_isxfile (GH-29906)
1 parent5bb7ef2 commit7d7c91a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎Modules/getpath.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ getpath_isdir(PyObject *Py_UNUSED(self), PyObject *args)
173173
path=PyUnicode_AsWideCharString(pathobj,NULL);
174174
if (path) {
175175
#ifdefMS_WINDOWS
176-
r= (GetFileAttributesW(path)&FILE_ATTRIBUTE_DIRECTORY) ?Py_True :Py_False;
176+
DWORDattr=GetFileAttributesW(path);
177+
r= (attr!=INVALID_FILE_ATTRIBUTES)&&
178+
(attr&FILE_ATTRIBUTE_DIRECTORY) ?Py_True :Py_False;
177179
#else
178180
structstatst;
179181
r= (_Py_wstat(path,&st)==0)&&S_ISDIR(st.st_mode) ?Py_True :Py_False;
@@ -197,7 +199,9 @@ getpath_isfile(PyObject *Py_UNUSED(self), PyObject *args)
197199
path=PyUnicode_AsWideCharString(pathobj,NULL);
198200
if (path) {
199201
#ifdefMS_WINDOWS
200-
r= !(GetFileAttributesW(path)&FILE_ATTRIBUTE_DIRECTORY) ?Py_True :Py_False;
202+
DWORDattr=GetFileAttributesW(path);
203+
r= (attr!=INVALID_FILE_ATTRIBUTES)&&
204+
!(attr&FILE_ATTRIBUTE_DIRECTORY) ?Py_True :Py_False;
201205
#else
202206
structstatst;
203207
r= (_Py_wstat(path,&st)==0)&&S_ISREG(st.st_mode) ?Py_True :Py_False;
@@ -223,7 +227,9 @@ getpath_isxfile(PyObject *Py_UNUSED(self), PyObject *args)
223227
if (path) {
224228
#ifdefMS_WINDOWS
225229
constwchar_t*ext;
226-
r= (GetFileAttributesW(path)&FILE_ATTRIBUTE_DIRECTORY)&&
230+
DWORDattr=GetFileAttributesW(path);
231+
r= (attr!=INVALID_FILE_ATTRIBUTES)&&
232+
!(attr&FILE_ATTRIBUTE_DIRECTORY)&&
227233
SUCCEEDED(PathCchFindExtension(path,cchPath,&ext))&&
228234
(CompareStringOrdinal(ext,-1,L".exe",-1,1/* ignore case */)==CSTR_EQUAL)
229235
?Py_True :Py_False;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp