[New-bugs-announce] [issue31214] os.walk has a bug on Windows

Chris Lovett report at bugs.python.org
Tue Aug 15 18:41:39 EDT 2017


New submission from Chris Lovett:

When I walk a directory recursively, it is tacking on an additional non-existant file from one of the subdirectories.  Here's the code:

    def copy_dir(self, src, dest):
        result = sftp.mkdir(dest)
        for dirname, dirnames, filenames in os.walk(src):
            for subdirname in dirnames:
                print("entering dir:" + subdirname)
                self.copy_dir(os.path.join(src, subdirname), os.path.join(dest, subdirname))
            for filename in filenames:
                print("copying:" + filename)

Here's the output:

entering dir:include
copying:CallbackInterface.h
copying:ClockInterface.h
entering dir:tcc
copying:CallbackInterface.tcc
copying:CMakeLists.txt
copying:darknet.i
copying:darknet.i.h
copying:darknet.obj
copying:darknet.py
copying:darknetImageNetLabels.txt
copying:darknetPYTHON_wrap.cxx
copying:darknetPYTHON_wrap.h
copying:darknet_config.json
copying:demo.py
copying:demoHelper.py
copying:OpenBLASSetup.cmake
copying:runtest.sh
copying:schoolbus.png
copying:CallbackInterface.h
copying:ClockInterface.h
copying:CallbackInterface.tcc

The last 3 files listed here doesn't exist, they are a repeat of the files found in the subdirectories.

----------
components: Windows
messages: 300313
nosy: clovett, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: os.walk has a bug on Windows
type: behavior
versions: Python 3.6

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


More information about the New-bugs-announce mailing list