Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
caea7e8d
Commit
caea7e8d
authored
Jun 08, 2011
by
Brian Curtin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge
parent
ce5493f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
Lib/ntpath.py
Lib/ntpath.py
+12
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/posixmodule.c
Modules/posixmodule.c
+36
-0
No files found.
Lib/ntpath.py
View file @
caea7e8d
...
...
@@ -521,3 +521,15 @@ def relpath(path, start=curdir):
if
not
rel_list
:
return
curdir
return
join
(
*
rel_list
)
try
:
# The genericpath.isdir implementation uses os.stat and checks the mode
# attribute to tell whether or not the path is a directory.
# This is overkill on Windows - just pass the path to GetFileAttributes
# and check the attribute from there.
from
nt
import
_isdir
except
ImportError
:
from
genericpath
import
isdir
as
_isdir
def
isdir
(
path
):
return
_isdir
(
path
)
Misc/NEWS
View file @
caea7e8d
...
...
@@ -16,6 +16,9 @@ Core and Builtins
Library
-------
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
instead of os.stat.
- Issue #12080: Fix a performance issue in Decimal._power_exact that caused
some corner-case Decimal.__pow__ calls to take an unreasonably long time.
...
...
Modules/posixmodule.c
View file @
caea7e8d
...
...
@@ -4199,6 +4199,41 @@ win32_kill(PyObject *self, PyObject *args)
CloseHandle
(
handle
);
return
result
;
}
static
PyObject
*
posix__isdir
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
opath
;
char
*
path
;
PyUnicodeObject
*
po
;
DWORD
attributes
;
if
(
PyArg_ParseTuple
(
args
,
"U|:_isdir"
,
&
po
))
{
Py_UNICODE
*
wpath
=
PyUnicode_AS_UNICODE
(
po
);
attributes
=
GetFileAttributesW
(
wpath
);
if
(
attributes
==
INVALID_FILE_ATTRIBUTES
)
Py_RETURN_FALSE
;
goto
check
;
}
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear
();
if
(
!
PyArg_ParseTuple
(
args
,
"et:_isdir"
,
Py_FileSystemDefaultEncoding
,
&
path
))
return
NULL
;
attributes
=
GetFileAttributesA
(
path
);
if
(
attributes
==
INVALID_FILE_ATTRIBUTES
)
Py_RETURN_FALSE
;
check:
if
(
attributes
&
FILE_ATTRIBUTE_DIRECTORY
)
Py_RETURN_TRUE
;
else
Py_RETURN_FALSE
;
}
#endif
/* MS_WINDOWS */
#ifdef HAVE_PLOCK
...
...
@@ -8968,6 +9003,7 @@ static PyMethodDef posix_methods[] = {
{
"abort"
,
posix_abort
,
METH_NOARGS
,
posix_abort__doc__
},
#ifdef MS_WINDOWS
{
"_getfullpathname"
,
posix__getfullpathname
,
METH_VARARGS
,
NULL
},
{
"_isdir"
,
posix__isdir
,
METH_VARARGS
,
NULL
},
#endif
#ifdef HAVE_GETLOADAVG
{
"getloadavg"
,
posix_getloadavg
,
METH_NOARGS
,
posix_getloadavg__doc__
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment