Larry Hastings <la...@hastings.org> added the comment:

Actually I think Raymond makes a good point.

Re: symmetry: tbh that's nonsense.  The reason for symmetry among functions in 
the os module is because they do similar things--but this is because "form 
follows function".  We didn't decide to decorate functions with extra 
parameters just so they'd look nice.

The reason you want a function to support "dir_fd" is to make it safer; using 
functions taking "dir_fd" and some careful programming, you can prevent some 
forms of timing attack.  But we can't fix os.walk to make it safe in this 
way--which is why we have os.fwalk in the first place!  So users of os.walk 
with this problem simply don't need "dir_fd"--they need os.fwalk.

Re: performance: if some people care about performance here, and this approach 
is faster, then those people can just call os.fwalk directly.  This approach to 
os.walk(dir_fd=) just calls os.fwalk--so calling it directly could only be even 
faster.

(This is assuming my favored implementation which just calls os.fwalk--which is 
simple, and leverages os.fwalk doing a proper safe job of it.  If we use my 
hackier previous version, I suspect it only made os.walk slower.  Of course all 
of this is silly microbenchmarking anyway, and I'm not sure that these fiddling 
implementation details of os.walk / os.fwalk contribute to their runtime cost 
in any significant way.)


I counter-propose adding some text to os.walk steering people to os.fwalk for 
"advanced usage".  That might even be appropriate for 3.3 (beta 2).  I realize 
they are neighbors in the documentation, but it might save at least one 
benighted myopic soul.

I further propose to leave this issue open for now--there's no rush, 
really--and see if a compelling reason for os.walk(dir_fd=) appears.  If none 
does, then in the fullness of time we can close this as wontfix and move on, 
living our lives in the dazzling sunshine of righteous truth and justice.

Your move, Serhiy ;-)

p.s. Serhiy: yes, you can call os.fwalk() with dir_fd=None.  It would be 
*awful* if you could not!  And actually, os.fwalk didn't even support dir_fd 
until... 26 hours ago.

----------

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

Reply via email to