Comment 7 for bug 923575

Revision history for this message
Sara (sarahlish18) wrote :

Hi Andreas,

 I checked out the current trunk last night using the following command:

  bzr branch lp:python-mode # This is the correct command, isn't it? My py-version is now 6.0.5

 So, redoing the steps reported earlier leads to a new error:

   or: Wrong number of arguments: (lambda (&optional arg) "Looks for an appropriate mode function.

This does the following:
 - look for an interpreter with `py-choose-shell-by-shebang'
 - examine imports using `py-choose-shell-by-import'
 - if not successful, return default value of `py-shell-name'

With \\[universal-argument]) user is prompted to specify a reachable Python version." (interactive "P") (let ((erg (cond ((eq 4 (prefix-numeric-value arg)) (read-from-minibuffer "Python Shell\
: " py-shell-name)) (py-use-local-default (if (not (string= "" py-shell-local-path)) (expand-file-name py-shell-local-path) (message "Abort: `py-use-local-default' is set to `t' but `py-shell\
-local-path' is empty. Maybe call `py-toggle-local-default-use'"))) ((py-choose-shell-by-shebang)) ((py-choose-shell-by-import)) (t (default-value (quote py-shell-name)))))) (when (interactiv\
e-p) (message "%s" erg)) (setq py-shell-name erg) erg)), 3
Using `python-mode' version 6.0.5
You can run the command `py-version' with C-c C-v
or: Wrong number of arguments: (lambda (&optional arg) "Looks for an appropriate mode function.

This does the following:
 - look for an interpreter with `py-choose-shell-by-shebang'
 - examine imports using `py-choose-shell-by-import'
 - if not successful, return default value of `py-shell-name'

With \\[universal-argument]) user is prompted to specify a reachable Python version." (interactive "P") (let ((erg (cond ((eq 4 (prefix-numeric-value arg)) (read-from-minibuffer "Python Shell\
: " py-shell-name)) (py-use-local-default (if (not (string= "" py-shell-local-path)) (expand-file-name py-shell-local-path) (message "Abort: `py-use-local-default' is set to `t' but `py-shell\
-local-path' is empty. Maybe call `py-toggle-local-default-use'"))) ((py-choose-shell-by-shebang)) ((py-choose-shell-by-import)) (t (default-value (quote py-shell-name)))))) (when (interactiv\
e-p) (message "%s" erg)) (setq py-shell-name erg) erg)), 3

The solution is to amend line 7685 of python-mode.el to:
  (defun py-choose-shell (&rest arg)

But this still results in the same error. I found that the solution is to amend line 5753 of python-mode.el to:
  (format "import sys,imp\nif '%s' in sys.modules:\n imp.reload(%s)\nelse:\n import %s\n"
                                         m m m))

The reason is that has_key and reload has been removed in python3 (http://docs.python.org/release/3.0.1/whatsnew/3.0.html)

Doing the aforementioned changes fixes the bug on my PC.