[Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Mon May 13 22:43:32 EDT 2019


Steven D'Aprano writes:
 > On Tue, May 14, 2019 at 12:22:05AM +0300, Serge Matveenko wrote:
 > 
 > > As a regular library user, I see and expect no obvious difference
 > > between `os.symlink` and `shutil.symlink`. 
 > 
 > You "see ... no obvious difference" between two functions that live in 
 > completely different modules?
 > 
 > Isn't the fact that they live in *different modules* obvious
 > enough?

Please, Steve, you didn't need to go there.

Because it's not enough.  It's not unheard of for modules to include
functionality from other modules with "thin wrappers", merely to
change the calling convention, or even just to avoid an import.  Even
within the stdlib.  The point is that subtle issues like the presence
or absence of race conditions require careful reading of the
documentation, when some of said documentation may not even be in
Python in the case of modules like os.

If one of these has a race condition and the other doesn't, I think it
would be reasonable for the documentation of the racy one to
acknowledge the bug and point to the non-racy one.  I'm not sure it's
a great idea to put lots of effort into fixing shutils.  I just assume
that one is as risky (racy, risque) as any shell!


-- 
Associate Professor              Division of Policy and Planning Science
http://turnbull.sk.tsukuba.ac.jp/     Faculty of Systems and Information
Email: turnbull at sk.tsukuba.ac.jp                   University of Tsukuba
Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN


More information about the Python-ideas mailing list