-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to leave tempfile.NamedTemporaryFile around on close #43804
Comments
Hi, tempfile.NamedTemporaryFile provides a good interface One use-case that demonstrates where keeping the def update_conf(conf_path):
old = open(conf_path)
tmp = tempfile.NamedTemporaryFile(prefix =
os.basename(conf_path), \
dir = os.dirname(conf_path), delete = False)
for l in old:
tmp.write(l.replace('war', 'peace'))
close(old)
close(tmp)
os.link(conf_path, conf_path + ".old")
os.rename(tmp.name, conf_path) |
Logged In: YES oops, wrong Category: this should be Lib and not Modules |
Logged In: YES Why can't you store into an instance of StringIO instead of |
Logged In: YES As far as I can tell, StringIO doesn't actually create a |
Logged In: YES Here is an diff that includes a regress test |
Logged In: YES Right, it doesn't create a filesystem file. But that is the |
Logged In: YES Well, that would a) not be an atomic replacement and b) you |
Thanks for the patch, committed with doc changes as rev. 54344. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: