This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: os.listdir fails on debug build (windows)
Type: Stage:
Components: Interpreter Core Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kristjan.jonsson, ocean-city
Priority: critical Keywords: needs review, patch

Created on 2009-01-10 11:11 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
fix_thread_nt.patch ocean-city, 2009-01-10 11:11
Messages (3)
msg79538 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-01-10 11:11
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.
msg79540 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-01-10 12:08
I see, so it was I that caused this :)
I will owe up to it and submit a fix.
msg79543 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-01-10 12:14
Checked in:
Completed: At revision: 68476
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49156
2009-01-10 12:14:50kristjan.jonssonsetstatus: open -> closed
resolution: fixed
messages: + msg79543
2009-01-10 12:08:12kristjan.jonssonsetnosy: + kristjan.jonsson
messages: + msg79540
2009-01-10 11:11:50ocean-citycreate