homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients brett.cannon, ncoghlan, neologix, pitrou, r.david.murray, vstinner
Date 2011年10月12日.16:51:01
SpamBayes Score 1.4432899e-15
Marked as misclassified No
Message-id <1318438036.3235.2.camel@localhost.localdomain>
In-reply-to <1318437478.07.0.163853157813.issue13146@psf.upfronthosting.co.za>
Content
> > This new patch also fixes importlib.
> 
> """
> path_tmp = path + '.tmp'
> with _io.FileIO(path_tmp, 'wb') as file:
> file.write(data)
> _os.rename(path_tmp, path)
> """
> 
> I don't know exactly the context in which this code runs, but you can
> have a corruption if multiple processes try to write the bytecode file
> at the same time, since they'll all open the .tmp file: it should be
> opened with O_EXCL.
Or perhaps append the PID to the name of the temp file ?
(easier done in Python than in C :-))
> Also, as a side note, I'm wondering whether this type of check:
> """
> if not sys.platform.startswith('win'):
> # On POSIX-like platforms, renaming is atomic
> """
> 
> couldn't be rewritten as
> """
> if os.name == 'posix':
> # On POSIX-like platforms, renaming is atomic
> """
No, because os.py is not available to importlib (which must be
bootstrappable early). See the _bootstrap.py header for information
about what is available; this is also why we use FileIO instead of
open().
> Fox example, does OS-X report as POSIX?
I think so.
History
Date User Action Args
2011年10月12日 16:51:02pitrousetrecipients: + pitrou, brett.cannon, ncoghlan, vstinner, r.david.murray, neologix
2011年10月12日 16:51:01pitroulinkissue13146 messages
2011年10月12日 16:51:01pitroucreate

AltStyle によって変換されたページ (->オリジナル) /