Skip to main content

os.replace() backport for Python 2.x

Project description

Backport of os.replace()

http://docs.python.org/3.3/library/os.html#os.replace

http://bugs.python.org/issue8828

Suggested usage:

import sys
if sys.version_info > (3, 3):
    from os import replace
elif sys.platform == "win32":
    from osreplace import replace
else:
    # POSIX rename() is always atomic
    from os import rename as replace

Python 3.x is not supported. Please upgrade to Python 3.3.

Technical details

The replace() function uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING flag. The flag can’t be used to rename directories so it’s not entirely equal to rename(P) on POSIX.

MoveFileEx() is NOT guaranteed to be atomic. Under certain and unknown circumstances it may silently fall back to a non atomic call to CopyFile(). MoveFileTransacted() could improve the situation but it requires Vista or newer.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365240%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/aa365241%28v=vs.85%29.aspx

Credits

Original patch by Antoine Pitrou.

Changelog

pyosreplace 0.1b1

Release date: 02-Jul-2013

  • initial beta release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyosreplace-0.1b1.win-amd64-py2.7.exe (229.2 kB view details)

Uploaded Source

pyosreplace-0.1b1.win-amd64-py2.6.exe (229.4 kB view details)

Uploaded Source

pyosreplace-0.1b1.win32-py2.7.exe (201.8 kB view details)

Uploaded Source

pyosreplace-0.1b1.win32-py2.6.exe (202.1 kB view details)

Uploaded Source

File details

Details for the file pyosreplace-0.1b1.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1b1.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 320fb98310a97bcff370b34cc696d0bb708619e2d6d35844d6c582e97e085120
MD5 bbd31ecd4766108b1e534e02a8f53dc7
BLAKE2b-256 5fc1c6275a851a1414081b7a1a218227389fbce215431696e3553d1dc5c7044a

See more details on using hashes here.

File details

Details for the file pyosreplace-0.1b1.win-amd64-py2.6.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1b1.win-amd64-py2.6.exe
Algorithm Hash digest
SHA256 18f32faa0ffdf121a09898f96c82ee556452d8dd0754527939cc34f359f6d81f
MD5 d7bcea47a960dcb081a569c6ab22cc29
BLAKE2b-256 458113f252db636cf23dc54a40f145c24534719387550a0297ef1f640c617144

See more details on using hashes here.

File details

Details for the file pyosreplace-0.1b1.win32-py2.7.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1b1.win32-py2.7.exe
Algorithm Hash digest
SHA256 095fba7a1d0a6772625a5881806073d68e0b4683dec0f42ab21cd699efaf5dd1
MD5 5ae8075d41ee7190aff864804bd85166
BLAKE2b-256 9099e0f4e538a9f49308617062d920313d99743ca2a3d61c0ca1a43fd7d47938

See more details on using hashes here.

File details

Details for the file pyosreplace-0.1b1.win32-py2.6.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1b1.win32-py2.6.exe
Algorithm Hash digest
SHA256 513b77f7ce1fc5e510804ce6a351a238ae1043f9664d37023f4b1a2901fbb987
MD5 f7bfa2159b181b1390baaec5c47db245
BLAKE2b-256 2576bd42a0ea590665691ec0adf4de987e8e88db23bf1e2742198c2942dbd5e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page