Nick Coghlan <ncogh...@gmail.com> added the comment:

Thanks for that Charles-François - do you mind if I adapt that for walkdir?

The changes I would make are basically those that Antoine pointed out:
- rather than replacing the dirpath entry, instead yield a 4-tuple that appends 
the dirfd attribute at the end*
- if the dup(fd) fails, fall back to assuming top is a string or bytes path

*I'm still interested in opinions on this aspect. I see 5 main possibilities:
- (dirfd, subdirs, files) triple (problematic for the reasons Antoine pointed 
out)
- (dirpath, subdirs, files, dirfd) 4-tuple
- ((dirpath, dirfd), subdirs, files) nested tuple
- (dirpath, subdirs, files) tuple subclass with separate dirfd attribute
- (dirpath, subdirs, files) triple with dirpath as a str subclass with a 
separate fd attribute

I'm currently leaning towards the simple 4-tuple approach - it's simple, 
explicit and the walkdir pipeline operations can easily accept either 
underlying iterable by using indexing operations rather than tuple unpacking (a 
change I already planned to make so that the pipeline passed along the objects 
from the underlying iterable, anyway)

(I'll also need to create ctypes-based variants of all the relevant *at 
functions, since the stdlib wrappers won't be available in existing versions of 
Python)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13734>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to