[ python-Bugs-1608818 ] Sloppy error checking in listdir() for Posix

SourceForge.net noreply at sourceforge.net
Mon Dec 4 23:34:06 CET 2006


Bugs item #1608818, was opened at 2006-12-04 17:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1608818&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stephan R.A. Deibel (sdeibel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Sloppy error checking in listdir() for Posix

Initial Comment:
In the Linux/Unix (non-Windows / non-OS2) implementation of listdir() in posixmodule.c, a check for errno != 0 is done after the loop.  This assumes that errno is only set by readdir() but in fact it's possible for it to be set in PyUnicode_FromEncodedObject() if codecs are used in the conversion (actually that's a separate bug I'll report when I've investigated it futher).

To tighten this up, I'd recommend moving the errno != 0 clause in its entirety to just after the readdir() call and possibly resetting errno=0 before the readdir() call so it's clear the error really happened there.

I've attached a possible patch for this.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1608818&group_id=5470


More information about the Python-bugs-list mailing list