Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c8c0249c
Kaydet (Commit)
c8c0249c
authored
Eyl 25, 2018
tarafından
Joe Pamer
Kaydeden (comit)
Miss Islington (bot)
Eyl 25, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32557: allow shutil.disk_usage to take a file path on Windows also (GH-9372)
https://bugs.python.org/issue32557
üst
604e7b99
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
shutil.rst
Doc/library/shutil.rst
+5
-2
test_shutil.py
Lib/test/test_shutil.py
+1
-0
2018-09-25-10-39-27.bpo-32557.Rs1bf9.rst
...S.d/next/Windows/2018-09-25-10-39-27.bpo-32557.Rs1bf9.rst
+1
-0
posixmodule.c
Modules/posixmodule.c
+27
-2
No files found.
Doc/library/shutil.rst
Dosyayı görüntüle @
c8c0249c
...
@@ -343,11 +343,14 @@ Directory and files operations
...
@@ -343,11 +343,14 @@ Directory and files operations
Return disk usage statistics about the given path as a :term:`named tuple`
Return disk usage statistics about the given path as a :term:`named tuple`
with the attributes *total*, *used* and *free*, which are the amount of
with the attributes *total*, *used* and *free*, which are the amount of
total, used and free space, in bytes.
On Windows, *path* must be
a
total, used and free space, in bytes.
*path* may be a file or
a
directory
; on Unix, it can be a file or directory
.
directory.
.. versionadded:: 3.3
.. versionadded:: 3.3
.. versionchanged:: 3.8
On Windows, *path* can now be a file or directory.
Availability: Unix, Windows.
Availability: Unix, Windows.
.. function:: chown(path, user=None, group=None)
.. function:: chown(path, user=None, group=None)
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
c8c0249c
...
@@ -1363,6 +1363,7 @@ class TestShutil(unittest.TestCase):
...
@@ -1363,6 +1363,7 @@ class TestShutil(unittest.TestCase):
"disk_usage not available on this platform"
)
"disk_usage not available on this platform"
)
def
test_disk_usage
(
self
):
def
test_disk_usage
(
self
):
usage
=
shutil
.
disk_usage
(
os
.
path
.
dirname
(
__file__
))
usage
=
shutil
.
disk_usage
(
os
.
path
.
dirname
(
__file__
))
self
.
assertEqual
(
usage
,
shutil
.
disk_usage
(
__file__
))
self
.
assertGreater
(
usage
.
total
,
0
)
self
.
assertGreater
(
usage
.
total
,
0
)
self
.
assertGreater
(
usage
.
used
,
0
)
self
.
assertGreater
(
usage
.
used
,
0
)
self
.
assertGreaterEqual
(
usage
.
free
,
0
)
self
.
assertGreaterEqual
(
usage
.
free
,
0
)
...
...
Misc/NEWS.d/next/Windows/2018-09-25-10-39-27.bpo-32557.Rs1bf9.rst
0 → 100644
Dosyayı görüntüle @
c8c0249c
Allow shutil.disk_usage to take a file path on Windows
Modules/posixmodule.c
Dosyayı görüntüle @
c8c0249c
...
@@ -10079,13 +10079,38 @@ os__getdiskusage_impl(PyObject *module, path_t *path)
...
@@ -10079,13 +10079,38 @@ os__getdiskusage_impl(PyObject *module, path_t *path)
{
{
BOOL
retval
;
BOOL
retval
;
ULARGE_INTEGER
_
,
total
,
free
;
ULARGE_INTEGER
_
,
total
,
free
;
DWORD
err
=
0
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
retval
=
GetDiskFreeSpaceExW
(
path
->
wide
,
&
_
,
&
total
,
&
free
);
retval
=
GetDiskFreeSpaceExW
(
path
->
wide
,
&
_
,
&
total
,
&
free
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if (retval == 0)
if
(
retval
==
0
)
{
return PyErr_SetFromWindowsErr(0);
if
(
GetLastError
()
==
ERROR_DIRECTORY
)
{
wchar_t
*
dir_path
=
NULL
;
dir_path
=
PyMem_New
(
wchar_t
,
path
->
length
+
1
);
if
(
dir_path
==
NULL
)
{
return
PyErr_NoMemory
();
}
wcscpy_s
(
dir_path
,
path
->
length
+
1
,
path
->
wide
);
if
(
_dirnameW
(
dir_path
)
!=
-
1
)
{
Py_BEGIN_ALLOW_THREADS
retval
=
GetDiskFreeSpaceExW
(
dir_path
,
&
_
,
&
total
,
&
free
);
Py_END_ALLOW_THREADS
}
/* Record the last error in case it's modified by PyMem_Free. */
err
=
GetLastError
();
PyMem_Free
(
dir_path
);
if
(
retval
)
{
goto
success
;
}
}
return
PyErr_SetFromWindowsErr
(
err
);
}
success:
return
Py_BuildValue
(
"(LL)"
,
total
.
QuadPart
,
free
.
QuadPart
);
return
Py_BuildValue
(
"(LL)"
,
total
.
QuadPart
,
free
.
QuadPart
);
}
}
#endif
/* MS_WINDOWS */
#endif
/* MS_WINDOWS */
...
...
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