[New-bugs-announce] [issue28299] DirEntry.is_dir() evaluates True for a file on Windows

David Staab report at bugs.python.org
Wed Sep 28 08:47:27 EDT 2016

New submission from David Staab:

I'm using Python 3.5.2 on Windows 10 Pro to run the following code with the attached file structure.

The test code is:
from os import DirEntry, scandir

def test_is_dir():
    for item in os.scandir(TEST_DIR):
        if item.is_dir:

TEST_DIR = '.'

The console output is:
Connected to pydev debugger (build 162.1967.10)

Process finished with exit code 0

I would expect to only see '.\20160707', but "if item.is_dir:" always evaluates to True.

I notice that changing the import line to "from os import DirEntry, scandir" yields the exception "ImportError: cannot import name 'DirEntry'".

components: Windows
files: testmodule.zip
messages: 277611
nosy: David Staab, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: DirEntry.is_dir() evaluates True for a file on Windows
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file44865/testmodule.zip

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list