Message164504
I checked the source in
c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/crt/src/open.c
and it seems that on Windows open() is more or less implemented as a wrapper of sopen(..., ..., SH_DENYNO, ...).
So the only reason that trying to reopen a NamedTemporaryFile fails on Windows is because when we reopen we need to use O_TEMPORARY.
The following works for unmodified python:
import os, tempfile
DATA = b"hello bob"
def temp_opener(name, flag, mode=0o777):
return os.open(name, flag | os.O_TEMPORARY, mode)
with tempfile.NamedTemporaryFile() as f:
f.write(DATA)
f.flush()
with open(f.name, "rb", opener=temp_opener) as f:
assert f.read() == DATA
assert not os.path.exists(f.name)
So maybe we should just define tempfile.opener(). |
|
Date |
User |
Action |
Args |
2012-07-01 23:45:49 | sbt | set | recipients:
+ sbt, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, eric.araujo, r.david.murray, brian.curtin, dabrahams, davide.rizzo, dlenski |
2012-07-01 23:45:48 | sbt | set | messageid: <1341186348.92.0.717832797592.issue14243@psf.upfronthosting.co.za> |
2012-07-01 23:45:48 | sbt | link | issue14243 messages |
2012-07-01 23:45:48 | sbt | create | |
|