[docs] [issue12970] os.wlak() consider some symlinks as dirs instead of non-dirs

Марк Коренберг report at bugs.python.org
Tue Sep 13 15:16:05 CEST 2011


Марк Коренберг <socketpair at gmail.com> added the comment:

Also, there is some mis-optimisation for followlinks=False: stat() and then lstat() will be called. Instead of one lstat().

Code may be rewritten as (but I don't know about cross-platform issues):
---------------------------------
if followlinks:
    mode = os.stat(path).st_mode
else:
    mode = os.lstat(path).st_mode

if stat.S_ISDIR(mode):
    dirs.append(path)
else:
    nondir.append(path)
---------------------------------
It will be much cleaner than current (or patched with my patch) implementation

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12970>
_______________________________________


More information about the docs mailing list