[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 800260c: python.el: Cleanup temp files even with
From: |
Fabi�n Ezequiel Gallina |
Subject: |
[Emacs-diffs] emacs-24 800260c: python.el: Cleanup temp files even with eval errors. |
Date: |
Sat, 27 Dec 2014 06:38:46 +0000 |
branch: emacs-24
commit 800260c4eb1e0ce2cc0a9a172c99f17ff47e0a6a
Author: Fabián Ezequiel Gallina <address@hidden>
Commit: Fabián Ezequiel Gallina <address@hidden>
python.el: Cleanup temp files even with eval errors.
* lisp/progmodes/python.el (python-shell-send-file): Make file-name
mandatory. Fix temp file removal in the majority of cases.
---
lisp/ChangeLog | 7 +++++++
lisp/progmodes/python.el | 32 +++++++++++++++-----------------
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b73732a..5c5dae1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
2014-12-27 Fabián Ezequiel Gallina <address@hidden>
+ python.el: Cleanup temp files even with eval errors.
+
+ * progmodes/python.el (python-shell-send-file): Make file-name
+ mandatory. Fix temp file removal in the majority of cases.
+
+2014-12-27 Fabián Ezequiel Gallina <address@hidden>
+
python.el: Handle file encoding for shell.
* progmodes/python.el (python-rx-constituents): Add coding-cookie.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 8bbbd69..d9422e5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2620,35 +2620,33 @@ When argument ARG is non-nil do not include decorators."
delete)
"Send FILE-NAME to inferior Python PROCESS.
If TEMP-FILE-NAME is passed then that file is used for processing
-instead, while internally the shell will continue to use FILE-NAME.
-If DELETE is non-nil, delete the file afterwards."
+instead, while internally the shell will continue to use
+FILE-NAME. If TEMP-FILE-NAME and DELETE are non-nil, then
+TEMP-FILE-NAME is deleted after evaluation is performed."
(interactive "fFile to send: ")
(let* ((process (or process (python-shell-get-or-create-process)))
(encoding (with-temp-buffer
(insert-file-contents
(or temp-file-name file-name))
(python-info-encoding)))
+ (file-name (expand-file-name
+ (or (file-remote-p file-name 'localname)
+ file-name)))
(temp-file-name (when temp-file-name
(expand-file-name
(or (file-remote-p temp-file-name 'localname)
- temp-file-name))))
- (file-name (or (when file-name
- (expand-file-name
- (or (file-remote-p file-name 'localname)
- file-name)))
- temp-file-name)))
- (when (not file-name)
- (error "If FILE-NAME is nil then TEMP-FILE-NAME must be non-nil"))
+ temp-file-name)))))
(python-shell-send-string
(format
(concat
- "import codecs; __pyfile = codecs.open('''%s''', encoding='''%s''');"
- "exec(compile(__pyfile.read().encode('''%s'''), '''%s''', 'exec'));"
- "__pyfile.close()%s")
- (or temp-file-name file-name) encoding encoding file-name
- (if delete (format "; import os; os.remove('''%s''')"
- (or temp-file-name file-name))
- ""))
+ "import codecs, os;"
+ "__pyfile = codecs.open('''%s''', encoding='''%s''');"
+ "__code = __pyfile.read().encode('''%s''');"
+ "__pyfile.close();"
+ (when (and delete temp-file-name)
+ (format "os.remove('''%s''');" temp-file-name))
+ "exec(compile(__code, '''%s''', 'exec'));")
+ (or temp-file-name file-name) encoding encoding file-name)
process)))
(defun python-shell-switch-to-shell ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 800260c: python.el: Cleanup temp files even with eval errors.,
Fabi�n Ezequiel Gallina <=