Eryk Sun <eryk...@gmail.com> added the comment:

This is the high-level shutil module, so why not try to use the resolved parent 
directory? 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)

Also, as noted in msg260022, nt._getdiskusage was overlooked when implementing 
PEP 529. The same applies to nt._getfinalpathname and nt._getvolumepathname. 
nt._getfullpathname works with bytes because it takes an argument-clinic 
`path_t` instead of `unicode` or `Py_UNICODE`. I think the other 3 should be 
rewritten to use path_t, but it's out of scope for this issue.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26330>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to