-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
avoid import of nearby temporary with %edit #4848
Conversation
use mk**s**temp now, and create files in subfolders. should close ipythongh-4731 Note that some part of the logic could now use http://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile That will be deleted on close and avoid IPython to track it.
code looks clean. Do you think this is worth having a test of the edit magic? otherwise, 👍 |
for tfile in self.tempfiles: | ||
try: | ||
os.unlink(tfile) | ||
except OSError: | ||
pass | ||
|
||
for tdir in self.tempdirs: | ||
try: | ||
os.rmdir(tdir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if there's anything left in the directory. I think that's fine, because temporary files should be cleaned up anyway, I just wanted to note it.
Unfortunately, |
what about using from |
Ahhhh ! Will look at that. |
I could used it, but it would require quite some change / addition : Using it as a context manager could be doable, but would require significant rework of the %edit magic and So I'm not 100% sure it is worth. |
avoid import of nearby temporary with %edit
avoid import of nearby temporary with %edit
use mkstemp now,
and create files in subfolders.
should close gh-4731
Note that some part of the logic could now use
http://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
That will be deleted on close and avoid IPython to track it.