Funky file contents when os.rename or os.remove are interrupted

hg hg at nospam.com
Tue Oct 10 14:39:33 EDT 2006


Russell Warren wrote:
> I've got a case where I'm seeing text files that are either all null
> characters, or are trailed with nulls due to interrupted file access
> resulting from an electrical power interruption on the WinXP pc.
> 
> In tracking it down, it seems that what is being interrupted is either
> os.remove(), or os.rename().  Has anyone seen this behaviour, or have
> any clue what is going on?
> 
> On first pass I would think that both of those calls are single step
> operations (removing/changing an entry in the FAT, or FAT-like thing,
> on the HDD) and wouldn't result in an intermediate, null-populated,
> step, but the evidence seems to indicate I'm wrong...
> 
> Any insight from someone with knowledge of the internal operations of
> os.remove and/or os.rename would be greatly appreciated, although I
> expect the crux may be at the os level and not in python.
> 
> Russ
> 
Taking a quick look at the code, it looks like MoveFileW (Windows API)
is eventually being called by posixmodule.c.

My gut feeling is that you are correct and not facing a Python but
Windows issue (sigh) ... you might want to test your problem on an NTFS
file system and see if the problems are similar.

Regards,

hg






More information about the Python-list mailing list