[New-bugs-announce] [issue4906] os.listdir fails on debug build (windows)

Hirokazu Yamamoto report at bugs.python.org
Sat Jan 10 12:11:51 CET 2009

New submission from Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp>:

Due to r68455, os.listdir fails on debug build (windows).


Python 2.7a0 (trunk, Jan 10 2009, 18:36:15) [MSC v.1200 32 bit (Intel)] 
on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import os
[33639 refs]
>>> os.listdir(".")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 0] この操作を正しく終了しました。: './*.*'
[33678 refs]


Probably a following XP Buildbot error comes from same reason.


This error is raised near Modules/posixmodule.c (2205)

	result = FindNextFile(hFindFile, &FileData);
	/* FindNextFile sets error to ERROR_NO_MORE_FILES if
	   it got to the end of the directory. */
	if (!result && GetLastError() != ERROR_NO_MORE_FILES) {

GetLastError() is sometimes 0 when should be ERROR_NO_MORE_FILES.
This happens because, on debug build, Py_END_ALLOW_THREADS finally
reaches PyThread_get_key_value in Python/thread_nt.h, and TlsGetValue
in it calls SetValueError(0) when function succeeds. See

I've attached the patch to fix this. I believe LastError set by
TlsGetValue on its failure is not used anywhere.

components: Interpreter Core
files: fix_thread_nt.patch
keywords: needs review, patch
messages: 79538
nosy: ocean-city
priority: critical
severity: normal
status: open
title: os.listdir fails on debug build (windows)
versions: Python 2.7
Added file: http://bugs.python.org/file12672/fix_thread_nt.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list