-
-
Notifications
You must be signed in to change notification settings - Fork 29.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
Turn NamedTemporaryFile into a context manager #46305
Comments
In the spirit of files becoming context managers in 2.5, the attached BTW, I was not able to add a "patch" keyword which seems appropriate here. |
Thanks for the patch! It even has a unit test, very good. :) The __future__ statement isn't necessary for Python 2.6. The with |
I've changed the issue type from rfe to behaviour. NamedTemporaryFile Fixed on the trunk in r60695. Leaving issue as pending until the P.S. Alexander's patch worked as written, but in figuring out *why* it |
Nick's comment made me think why NamedTemporaryFile can't simply It turned out that although file is subclassable, in its present form,
The attached patch fixes both issues and reimplements NamedTemporaryFile. I understand that adding new functionality to file objects should be The patch is proof-of-concept quality at the moment and may not work |
The wrapper approach has the virtue of providing easy access to the The wrapper approach also has the virtue of being a valid candidate for |
Backported to 2.5 in r60728 P.S. To elaborate a bit more on why converting NamedTemporaryFile to
|
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: