>> Very much agreed that this isn't necessary for just readdir/FindNext >> errors. We've never had this level of detail before -- if listdir() >> fails half way through (very unlikely) it just bombs with OSError and >> you get no entries at all. >> >> If you really really want this (again very unlikely), you can always >> use call next() directly and catch OSError around that call. > > Agreed - I think the PEP should point this out explicitly, and show that the > approach it takes offers a lot of flexibility in error handling from "just > let it fail", to a single try/catch around the whole loop, to try/catch just > around the operations that might call lstat(), to try/catch around the > individual iteration steps.
Good point. It'd be good to mention this explicitly in the PEP and have another example or two of the different levels of errors handling. > os.walk remains the higher level API that most code should be using, and > that has to retain the current listdir based behaviour (any error = ignore > all entries in that directory) for backwards compatibility reasons. Yes, definitely. -Ben _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com