T
Tony Meyer
On Windows, if I do os.rename(old, new) where old is a file that is
in-use (e.g. python itself, or a dll that is loaded), I would expect
that an error would be raised (e.g. as when os.remove is called with
an in-use file). However, what happens is that a copy of the file is
made, and the old file still exists.
For example:
C:\>c:\python24\python.exe
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
D:\>dir c:\python24\p*.exe
Volume in drive C is ACER
Volume Serial Number is 320D-180E
Directory of c:\python24
28/09/2005 12:41 p.m. 4,608 python.exe
28/09/2005 12:41 p.m. 5,120 pythonw.exe
2 File(s) 9,728 bytes
0 Dir(s) 16,018,685,952 bytes free
C:\>dir d:\p*24.exe
Volume in drive D is DATA
Volume Serial Number is 4019-78E0
Directory of d:\
28/09/2005 12:41 p.m. 4,608 python24.exe
1 File(s) 4,608 bytes
0 Dir(s) 15,362,207,744 bytes free
Is this the intended behaviour? The documentation doesn't give any
indication that it is (so unless I'm missing something, this is at
least a documentation bug).
Any insight appreciated
(I do know that I can work around it by
doing a remove after the rename, if the file exists).
=Tony.Meyer
in-use (e.g. python itself, or a dll that is loaded), I would expect
that an error would be raised (e.g. as when os.remove is called with
an in-use file). However, what happens is that a copy of the file is
made, and the old file still exists.
For example:
C:\>c:\python24\python.exe
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
D:\>dir c:\python24\p*.exe
Volume in drive C is ACER
Volume Serial Number is 320D-180E
Directory of c:\python24
28/09/2005 12:41 p.m. 4,608 python.exe
28/09/2005 12:41 p.m. 5,120 pythonw.exe
2 File(s) 9,728 bytes
0 Dir(s) 16,018,685,952 bytes free
C:\>dir d:\p*24.exe
Volume in drive D is DATA
Volume Serial Number is 4019-78E0
Directory of d:\
28/09/2005 12:41 p.m. 4,608 python24.exe
1 File(s) 4,608 bytes
0 Dir(s) 15,362,207,744 bytes free
Is this the intended behaviour? The documentation doesn't give any
indication that it is (so unless I'm missing something, this is at
least a documentation bug).
Any insight appreciated
doing a remove after the rename, if the file exists).
=Tony.Meyer