Author eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2018-01-15.15:26:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516030012.51.0.467229070634.issue32557@psf.upfronthosting.co.za>
In-reply-to
Content
Issue 26330 was resolved by documenting that shutil.disk_usage requires a directory. However, the shutil module is in a position to harmonize cross-platform behavior in ways that aren't normally possible or recommended in the low-level os module. To that end, the Windows implementation could retry calling nt._getdiskusage on the resolved parent directory in case of NotADirectoryError. For example:

    def disk_usage(path):
        try:
            total, free = nt._getdiskusage(path)
        except NotADirectoryError:
            path = os.path.dirname(nt._getfinalpathname(path))
            total, free = nt._getdiskusage(path)
        used = total - free
        return _ntuple_diskusage(total, used, free)

Alternatively, this could be addressed in the implementation of nt._getdiskusage itself.
History
Date User Action Args
2018-01-15 15:26:52eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2018-01-15 15:26:52eryksunsetmessageid: <1516030012.51.0.467229070634.issue32557@psf.upfronthosting.co.za>
2018-01-15 15:26:52eryksunlinkissue32557 messages
2018-01-15 15:26:52eryksuncreate