[merge] don't treat enoent from readdir as indicating eof

Martin Pool mbp at canonical.com
Tue Oct 7 06:17:28 BST 2008

As a follow on from my previous patch, this makes ENOENT from readdir
just be treated as a regular error.

I can't find any clear indication on the web of what would be the
correct way to handle it, and it seems unlikely that it will be
raised.  I think if we were seeing it before, it probably was because
of bug 279381.  It seems to me that unless we specifically know that
it indicates the end of the directory, it's unsafe to treat it as
such.   If we merge this change and it causes a real exception, we can
find out more about situations where it does occur.

=== modified file 'bzrlib/_readdir_pyx.pyx'
--- bzrlib/_readdir_pyx.pyx     2008-10-07 04:39:43 +0000
+++ bzrlib/_readdir_pyx.pyx     2008-10-07 05:13:20 +0000
@@ -301,15 +301,10 @@
             if entry == NULL:
-                if errno == ENOTDIR or errno == ENOENT or errno == 0:
+                if errno == ENOTDIR or errno == 0:
                     # We see ENOTDIR at the end of a normal directory.
                     # As ENOTDIR for read_dir(file) is triggered on opendir,
                     # we consider ENOTDIR to be 'no error'.
-                    #
-                    # XXX: ENOENT is listed as 'invalid position in
the dir stream' for
-                    # readdir.  It's not clear what we should do about that
-                    # case; at the moment we treat it as the end of the
-                    # directory.
                     raise OSError(errno, strerror(errno))

Martin <http://launchpad.net/~mbp/>

More information about the bazaar mailing list