emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 376a31b 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/g


From: Eli Zaretskii
Subject: master 376a31b 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Date: Sat, 11 Sep 2021 10:50:59 -0400 (EDT)

branch: master
commit 376a31b0cdf64f4264904e2a9d49216959a35bd2
Merge: c7aaf2f 84e35ff
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
---
 lisp/net/tramp-gvfs.el       |  8 ++++----
 lisp/net/tramp-sh.el         |  4 ++--
 lisp/progmodes/python.el     | 49 +++++++++++++++++++++++++++++---------------
 test/lisp/net/tramp-tests.el | 45 ++++++++++++----------------------------
 4 files changed, 52 insertions(+), 54 deletions(-)

diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index eb889bb..25deead 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1574,10 +1574,10 @@ If FILE-SYSTEM is non-nil, return file system 
attributes."
        (when (and parents (not (file-directory-p ldir)))
          (make-directory ldir parents))
        ;; Just do it.
-       (or (let ((mkdir-succeeded
-                  (tramp-gvfs-send-command
-                   v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
-             (if mkdir-succeeded (set-file-modes dir (default-file-modes)))
+       (or (when-let ((mkdir-succeeded
+                       (tramp-gvfs-send-command
+                        v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
+             (set-file-modes dir (default-file-modes))
              mkdir-succeeded)
            (and parents (file-directory-p dir))
            (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e57145e..dc04978 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -244,14 +244,14 @@ The string is used in `tramp-methods'.")
  (add-to-list 'tramp-methods
               `("telnet"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p") ("%n")))
+                (tramp-login-args           (("%h") ("%p")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))))
  (add-to-list 'tramp-methods
               `("nc"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p") ("%n")))
+                (tramp-login-args           (("%h") ("%p")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e71a810..d9fc5c5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2842,14 +2842,20 @@ def __PYTHON_EL_eval(source, filename):
 
 (defconst python-shell-eval-file-setup-code
   "\
-def __PYTHON_EL_eval_file(filename, tempname, encoding, delete):
-    import codecs, os
+def __PYTHON_EL_eval_file(filename, tempname, delete):
+    import codecs, os, re
+    pattern = r'^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)'
+    with codecs.open(tempname or filename, encoding='latin-1') as file:
+        match = re.match(pattern, file.readline())
+        match = match or re.match(pattern, file.readline())
+        encoding = match.group(1) if match else 'utf-8'
     with codecs.open(tempname or filename, encoding=encoding) as file:
         source = file.read().encode(encoding)
     if delete and tempname:
         os.remove(tempname)
     return __PYTHON_EL_eval(source, filename)"
-  "Code used to evaluate files in inferior Python processes.")
+  "Code used to evaluate files in inferior Python processes.
+The coding cookie regexp is specified in PEP 263.")
 
 (defun python-shell-comint-watch-for-first-prompt-output-filter (output)
   "Run `python-shell-first-prompt-hook' when first prompt is found in OUTPUT."
@@ -3126,7 +3132,9 @@ there for compatibility with CEDET.")
          (temp-file-name (make-temp-file "py"))
          (coding-system-for-write (python-info-encoding)))
     (with-temp-file temp-file-name
-      (insert string)
+      (if (bufferp string)
+          (insert-buffer-substring string)
+        (insert string))
       (delete-trailing-whitespace))
     temp-file-name))
 
@@ -3155,7 +3163,9 @@ t when called interactively."
                       (python-shell--encode-string (or (buffer-file-name)
                                                        "<string>")))))
     (if (or (null (process-tty-name process))
-            (<= (string-bytes code) comint-max-line-length))
+            (<= (string-bytes code)
+                (or (bound-and-true-p comint-max-line-length)
+                    1024))) ;; For Emacs < 28
         (comint-send-string process code)
       (let* ((temp-file-name (with-current-buffer (process-buffer process)
                                (python-shell--save-temp-file string)))
@@ -3402,11 +3412,15 @@ t when called interactively."
 (defun python-shell-send-file (file-name &optional process temp-file-name
                                          delete msg)
   "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 TEMP-FILE-NAME and DELETE are non-nil, then
-TEMP-FILE-NAME is deleted after evaluation is performed.  When
-optional argument MSG is non-nil, forces display of a
+FILE-NAME.  FILE-NAME can be remote, but TEMP-FILE-NAME must be
+in the same host as PROCESS.  If TEMP-FILE-NAME and DELETE are
+non-nil, then TEMP-FILE-NAME is deleted after evaluation is
+performed.
+
+When optional argument MSG is non-nil, forces display of a
 user-friendly message if there's no process running; defaults to
 t when called interactively."
   (interactive
@@ -3416,22 +3430,25 @@ t when called interactively."
     nil                                 ; temp-file-name
     nil                                 ; delete
     t))                                 ; msg
-  (let* ((process (or process (python-shell-get-process-or-error msg)))
-         (encoding (with-temp-buffer
-                     (insert-file-contents
-                      (or temp-file-name file-name))
-                     (python-info-encoding)))
-         (file-name (file-local-name (expand-file-name file-name)))
+  (setq process (or process (python-shell-get-process-or-error msg)))
+  (with-current-buffer (process-buffer process)
+    (unless (or temp-file-name
+                (string= (file-remote-p file-name)
+                         (file-remote-p default-directory)))
+      (setq delete t
+            temp-file-name (with-temp-buffer
+                             (insert-file-contents file-name)
+                             (python-shell--save-temp-file 
(current-buffer))))))
+  (let* ((file-name (file-local-name (expand-file-name file-name)))
          (temp-file-name (when temp-file-name
                            (file-local-name (expand-file-name
                                              temp-file-name)))))
     (comint-send-string
      process
      (format
-      "__PYTHON_EL_eval_file(%s, %s, %s, %s)\n"
+      "__PYTHON_EL_eval_file(%s, %s, %s)\n"
       (python-shell--encode-string file-name)
       (python-shell--encode-string (or temp-file-name ""))
-      (python-shell--encode-string (symbol-name encoding))
       (if delete "True" "False")))))
 
 (defun python-shell-switch-to-shell (&optional msg)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 393302d..af4f45d 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2765,12 +2765,12 @@ This checks also `file-name-as-directory', 
`file-name-directory',
            (ignore-errors (delete-directory source 'recursive))
            (ignore-errors (delete-directory target 'recursive))))))))
 
-(defun tramp-test-make-directory-helper (test-default-file-modes-p)
-  "Helper test used by tramp-test13-make-directory* tests."
-  (dolist (quoted (if (and (tramp--test-expensive-test)
-                           (not test-default-file-modes-p))
-                      '(nil t)
-                    '(nil)))
+(ert-deftest tramp-test13-make-directory ()
+  "Check `make-directory'.
+This tests also `file-directory-p' and `file-accessible-directory-p'."
+  (skip-unless (tramp--test-enabled))
+
+  (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
           (tmp-name2 (expand-file-name "foo/bar" tmp-name1))
           (unusual-file-mode-1 #o740)
@@ -2784,9 +2784,9 @@ This checks also `file-name-as-directory', 
`file-name-directory',
             :type 'file-already-exists)
            (should (file-directory-p tmp-name1))
            (should (file-accessible-directory-p tmp-name1))
-           (and test-default-file-modes-p
-                (should (equal (format "%#o" unusual-file-mode-1)
-                               (format "%#o" (file-modes tmp-name1)))))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-1)
+                            (format "%#o" (file-modes tmp-name1)))))
            (should-error
             (make-directory tmp-name2)
             :type 'file-error)
@@ -2794,9 +2794,9 @@ This checks also `file-name-as-directory', 
`file-name-directory',
              (make-directory tmp-name2 'parents))
            (should (file-directory-p tmp-name2))
            (should (file-accessible-directory-p tmp-name2))
-           (and test-default-file-modes-p
-                (should (equal (format "%#o" unusual-file-mode-2)
-                               (format "%#o" (file-modes tmp-name2)))))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-2)
+                            (format "%#o" (file-modes tmp-name2)))))
            ;; If PARENTS is non-nil, `make-directory' shall not
            ;; signal an error when DIR exists already.
            (make-directory tmp-name2 'parents))
@@ -2804,20 +2804,6 @@ This checks also `file-name-as-directory', 
`file-name-directory',
        ;; Cleanup.
        (ignore-errors (delete-directory tmp-name1 'recursive))))))
 
-(ert-deftest tramp-test13-make-directory ()
-  "Check `make-directory'.
-This tests also `file-directory-p' and `file-accessible-directory-p'."
-  (skip-unless (tramp--test-enabled))
-  (tramp-test-make-directory-helper nil))
-
-(ert-deftest tramp-test13-make-directory-with-file-modes ()
-  "Check that `make-directory' honors `default-file-modes'.
-This is a separate test from `tramp-test13-make-directory' so
-it can be skipped for backends that do not support file modes."
-  (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-supports-file-modes-p))
-  (tramp-test-make-directory-helper t))
-
 (ert-deftest tramp-test14-delete-directory ()
   "Check `delete-directory'."
   (skip-unless (tramp--test-enabled))
@@ -6763,11 +6749,6 @@ process sentinels.  They shall not disturb each other."
             (cond
              ((getenv "EMACS_HYDRA_CI") 10)
              (t 1)))
-           ;; We must distinguish due to performance reasons.
-           (timer-operation
-            (cond
-             ((tramp--test-mock-p) #'vc-registered)
-             (t #'file-attributes)))
           ;; This is when all timers start.  We check inside the
           ;; timer function, that we don't exceed timeout.
           (timer-start (current-time))
@@ -6803,7 +6784,7 @@ process sentinels.  They shall not disturb each other."
                           (cons 'remote-file-error debug-ignored-errors)))
                       (tramp--test-message
                        "Start timer %s %s" file (current-time-string))
-                     (funcall timer-operation file)
+                     (vc-registered file)
                       (tramp--test-message
                        "Stop timer %s %s" file (current-time-string))
                       ;; Adjust timer if it takes too much time.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]