user configured `py-shell-name' is not honored by 'py-guess-default-python'

Bug #920079 reported by yagnesh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

suppose I have configured my py-shell-name like

(add-hook 'python-mode-hook
          (lambda ()
            (setq py-shell-name "python3.2")))

and in my file if shebang only contains python. py-guess-default-python sets py-shell-name to python and thus not honoring the user preference.

possible simple fix might be

=== modified file 'python-mode.el'
*** python-mode.el 2012-01-22 15:14:14 +0000
--- python-mode.el 2012-01-22 17:12:51 +0000
***************
*** 4978,4984 ****
  (defun py-guess-default-python ()
    "If any Python is installed. Used by `py-shell' if `py-shell-name' is neither selected nor has a customized default value. "
    (interactive)
! (let* ((cmd (or (py-choose-shell) "python"))
           (erg (executable-find cmd)))
      (when (interactive-p)
        (if erg
--- 4978,4984 ----
  (defun py-guess-default-python ()
    "If any Python is installed. Used by `py-shell' if `py-shell-name' is neither selected nor has a customized default value. "
    (interactive)
! (let* ((cmd (or py-shell-name (py-choose-shell) "python"))
           (erg (executable-find cmd)))
      (when (interactive-p)
        (if erg

Revision history for this message
yagnesh (yagnesh) wrote :

Hello Andreas.,

I was wondering, is it okay to post bug reports in the mailling list instead.?

Revision history for this message
yagnesh (yagnesh) wrote :

scratch above fix

seems main place to fix is py-choose-shell

Here is the diff

***************
*** 7563,7577 ****

  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 py-shell-name))))
      (when (interactive-p) (message "%s" erg))
      (setq py-shell-name erg)
      erg))
--- 7564,7580 ----

  With \\[universal-argument]) user is prompted to specify a reachable Python version."
    (interactive "P")
! (let ((erg (cond
! (py-shell-name py-shell-name)
! ((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 nil))))
      (when (interactive-p) (message "%s" erg))
      (setq py-shell-name erg)
      erg))

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.5
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 920079] Re: user configured `py-shell-name' is not honored by 'py-guess-default-python'

Am 22.01.2012 18:22, schrieb yagnesh:
> Hello Andreas.,
>
> I was wondering, is it okay to post bug reports in the mailling list
> instead.?
>

Hi Yagnesh,

thanks for the report.

As for your question: no, rather not.

In some rare cases of general interest a cc might be appropriate though.

Cheers,

Andreas

Revision history for this message
yagnesh (yagnesh) wrote :

Thanks for the prompt reply.

I am kinda getting familiar with bzr and launchpad.
I hope to contribute to python-mode in the near future.

If I may ask how do you access the bug reports.? would you go to the browser or is there any way to access these with in the emacs.?

Thanks
Yagnesh

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Am 22.01.2012 19:29, schrieb yagnesh:
> Thanks for the prompt reply.
>
> I am kinda getting familiar with bzr and launchpad.
> I hope to contribute to python-mode in the near future.

Hi Yagnesh,

that's great.

>
> If I may ask how do you access the bug reports.? would you go to the
> browser or is there any way to access these with in the emacs.?
>

When committing you may link a commit by specifying it

bzr commit --fixes=lp:123456 -m 'My-MESSAGE'

Afterwards, when going through the reports, change flags by browser
buttons if needed.

Not sure this is the best. Exists also an email-interface

https://help.launchpad.net/Bugs/EmailInterface

Best,

Andreas

> Thanks
> Yagnesh
>

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 920079] [NEW] user configured `py-shell-name' is not honored by 'py-guess-default-python'

Am 22.01.2012 18:20, schrieb yagnesh:

Hi Yagnesh,

assume something different must have went wrong.

`py-guess-default-python' is used only once AFAIS,

from inside py-shell

                 ((or (string= "" py-shell-name)(null py-shell-name))
                  (py-guess-default-python))))

i.e. it only comes in, when `py-shell-name' was found empty.

Please make a complete report, describe what you are going to perform.

Thanks digging in,

Andreas

Changed in python-mode:
status: New → Incomplete
milestone: 6.0.5 → none
assignee: Andreas Roehler (a-roehler) → nobody
Revision history for this message
Andreas Roehler (a-roehler) wrote :

sorry, my mistake, you are right, seeing the bug now.

Cheers,

Andreas

Changed in python-mode:
status: Incomplete → In Progress
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.5
Changed in python-mode:
status: In Progress → Fix Committed
Revision history for this message
yagnesh (yagnesh) wrote :

Thanks for the fix andreas,
this fix is fixes the problem.

But I am still suspicious about the line 7610 (in the py-choose-shell defun), where the 'cond' finally settles with py-shell-name.
What if user haven't set the the variable.? then cond' yields to nil.
That means that py-choose-shell returns with 'nil' which is not I believe it is supposed to do.

Anyhow so far, I haven't had any problem. please consider this as fixed.

BTW thanks for the bzr instructions

Thanks

Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.