Show More
@@ -260,7 +260,12 b" def atomic_writing(path, text=True, encoding='utf-8', **kwargs):" | |||||
260 | **kwargs |
|
260 | **kwargs | |
261 | Passed to :func:`io.open`. |
|
261 | Passed to :func:`io.open`. | |
262 | """ |
|
262 | """ | |
263 | path = os.path.realpath(path) # Dereference symlinks |
|
263 | # realpath doesn't work on Windows: http://bugs.python.org/issue9949 | |
|
264 | # Luckily, we only need to resolve the file itself being a symlink, not | |||
|
265 | # any of its directories, so this will suffice: | |||
|
266 | if os.path.islink(path): | |||
|
267 | path = os.path.join(os.path.dirname(path), os.readlink(path)) | |||
|
268 | ||||
264 | dirname, basename = os.path.split(path) |
|
269 | dirname, basename = os.path.split(path) | |
265 | handle, tmp_path = tempfile.mkstemp(prefix=basename, dir=dirname, text=text) |
|
270 | handle, tmp_path = tempfile.mkstemp(prefix=basename, dir=dirname, text=text) | |
266 | if text: |
|
271 | if text: |
General Comments 0
You need to be logged in to leave comments.
Login now