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.1 is not supported. Please upgrade to Python 3.2 or better.

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.1

Release date: 05-Nov-2013

  • Python 3.2 support

  • tox for testing

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 Distribution

pyosreplace-0.1.zip (10.5 kB view details)

Uploaded Source

Built Distributions

pyosreplace-0.1.win-amd64-py3.2.exe (229.8 kB view details)

Uploaded Source

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

Uploaded Source

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

Uploaded Source

pyosreplace-0.1.win32-py3.2.exe (201.9 kB view details)

Uploaded Source

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

Uploaded Source

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

Uploaded Source

File details

Details for the file pyosreplace-0.1.zip.

File metadata

  • Download URL: pyosreplace-0.1.zip
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyosreplace-0.1.zip
Algorithm Hash digest
SHA256 3b4a587525cf2d98deae834a5263163250b370d463da4d78721dda13f254ad41
MD5 b1a392c7b000a7f8d94e471fc72472aa
BLAKE2b-256 1e73ce3f6bcc91ae170569d3ab00bfd2a725607497ad2eb434f3ac27684635be

See more details on using hashes here.

File details

Details for the file pyosreplace-0.1.win-amd64-py3.2.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1.win-amd64-py3.2.exe
Algorithm Hash digest
SHA256 d5738dea1b7e1bde70680fd330aaf31052122971c1068f315f7001db45a78da8
MD5 56d9a352923deb269d4382794dab7d8e
BLAKE2b-256 4a8eb0ca76d872082f5967f16d637021402289df5367af1de4afda04b83c2637

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyosreplace-0.1.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 33f9742e7a3a664ec0048d8744458770e579326ee70b3d7c2106018f2764a2d0
MD5 999d6ed2533ade1c8c01fd76cbd9f968
BLAKE2b-256 2f3df49c166270703b82d3c2f62ce087fc87a8c724252c7c4af908ca48c2148f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyosreplace-0.1.win-amd64-py2.6.exe
Algorithm Hash digest
SHA256 1cba5df4a39a439e054914b7ec0f2acbad3c90a50969c69fce9c3b95be2e1c47
MD5 38de50ec917a3579f2436ebc9bc941bd
BLAKE2b-256 83d94123256c8d9769ff73af98931834cb64d8c2b57605ca7f2b0256d8ad7c7b

See more details on using hashes here.

File details

Details for the file pyosreplace-0.1.win32-py3.2.exe.

File metadata

File hashes

Hashes for pyosreplace-0.1.win32-py3.2.exe
Algorithm Hash digest
SHA256 4a57c9dd6ac38dcdbc6181f5f22476f78e0aef3dc9d2e450324122c5523b485a
MD5 8b438b5b2064d0f8863b8fd90ef6d602
BLAKE2b-256 5631b0284098c829246f9740493f540628fb3c077358206dc92943589b4179d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyosreplace-0.1.win32-py2.7.exe
Algorithm Hash digest
SHA256 bd7917434328f6ea5449e7dc28d835ca85515b2a3aa1128694fcd75be9f6a410
MD5 fa9f70be6bd4a9c1861bee8a3a523a3d
BLAKE2b-256 07ea4f3ded4b1775aaae1426e34c22889b3b59c7863202baa1140fff299e7ec3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyosreplace-0.1.win32-py2.6.exe
Algorithm Hash digest
SHA256 e00fb2f7f25b6092913c735538c202a31016b89640457decca3ae779d88dad9f
MD5 a682e68d4b5ba9c5cdb836b3ed56d755
BLAKE2b-256 f39c058dd280ed3354dd21475cde26b375d6da042590e10968ce796c88827355

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