opening Pymacs.py fails

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

Bug Description

Hi, Andreas.

Opening ~/entretien/pymacs/Pymacs.py fails with this traceback (I merely
M-C-x'ed a few functions from source so the traceback becomes useful).
Comments follow.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("/home/pinard/bureautique/emacs/_/python-mode/Pymacs" nil)
  (let* ((pyshell ...) (path ...) (pymacs-installed-p ...)) (unless pymacs-installed-p (setenv "PYTHONPATH" ...)) (if (or ... ...) (error "`py-install-directory' not set, see INSTALL") (load ... nil t) (setenv "PYMACS_PYTHON" ...) (autoload ... "pymacs") (autoload ... "pymacs") (autoload ... "pymacs") (autoload ... "pymacs") (autoload ... "pymacs") (require ...)) (unwind-protect (progn ... ...)) (kill-buffer "pycomplete.el"))
  py-load-pymacs()
  (progn (py-load-pymacs) (unwind-protect (progn ... ...)) (kill-buffer "pycomplete.el"))
  (if py-load-pymacs-p (progn (py-load-pymacs) (unwind-protect ...) (kill-buffer "pycomplete.el")))
  (when py-load-pymacs-p (py-load-pymacs) (unwind-protect (progn ... ...)) (kill-buffer "pycomplete.el"))
  (let ((delay-mode-hooks t)) (kill-all-local-variables) (setq major-mode (quote python-mode)) (setq mode-name "Python") nil (use-local-map python-mode-map) (set-syntax-table python-mode-syntax-table) (setq local-abbrev-table python-mode-abbrev-table) (set (make-local-variable ...) (quote ...)) (set (make-local-variable ...) t) (set (make-local-variable ...) t) (set (make-local-variable ...) "# ") (set (make-local-variable ...) "^[ ]*#+ *") (set (make-local-variable ...) 40) (set (make-local-variable ...) (function py-comment-indent-function)) (set (make-local-variable ...) (quote py-indent-region)) (set (make-local-variable ...) (quote py-indent-line)) (add-to-list (quote hs-special-modes-alist) (list ... ... nil "#" ... nil)) (set (make-local-variable ...) ":\\s-*\n") (set (make-local-variable ...) (function python-outline-level)) (set (make-local-variable ...) nil) (set (make-local-variable ...) (concat ... ...)) (set (make-local-variable ...) (quote py-current-defun)) (set (make-local-variable ...) "\\s-*$") (set (make-local-variable ...) (quote py-fill-paragraph)) (set (make-local-variable ...) mode-require-final-newline) (make-local-variable (quote python-saved-check-command)) (set (make-local-variable ...) (quote py-beginning-of-def-or-class)) (set (make-local-variable ...) (quote py-end-of-def-or-class)) (add-hook (quote which-func-functions) (quote python-which-func) nil t) (when (and imenu-create-index-p ...) (setq imenu-create-index-function ...) (setq imenu-generic-expression py-imenu-generic-expression) (when ... ... ...)) (set (make-local-variable ...) (function python-eldoc-function)) (add-hook (quote eldoc-mode-hook) (lambda nil ...) nil t) (add-hook (quote completion-at-point-functions) py-complete-function nil (quote local)) (set (make-local-variable ...) (quote ...)) (set (make-local-variable ...) py-indent-offset) (when py-smart-indentation (if ... ... ...)) (when (null py-shell-name) (py-toggle-shells ...)) (when py-load-pymacs-p (py-load-pymacs) (unwind-protect ...) (kill-buffer "pycomplete.el")) (define-key inferior-python-mode-map (kbd "<tab>") (quote python-shell-completion-complete-or-indent)) (if py-menu (easy-menu-add py-menu)) (when py-hide-show-minor-mode-p (hs-minor-mode 1)) (run-mode-hooks (if python-mode-hook ... ...)) (when py-start-run-py-shell (window-configuration-to-register 213465879) (unless ... ...) (jump-to-register 213465879)) (when py-outline-minor-mode-p (outline-minor-mode 1)) (when (interactive-p) (message "python-mode loaded from: %s" "python-mode.el")))
  (progn (make-local-variable (quote delay-mode-hooks)) (let (...) (kill-all-local-variables) (setq major-mode ...) (setq mode-name "Python") nil (use-local-map python-mode-map) (set-syntax-table python-mode-syntax-table) (setq local-abbrev-table python-mode-abbrev-table) (set ... ...) (set ... t) (set ... t) (set ... "# ") (set ... "^[ ]*#+ *") (set ... 40) (set ... ...) (set ... ...) (set ... ...) (add-to-list ... ...) (set ... ":\\s-*\n") (set ... ...) (set ... nil) (set ... ...) (set ... ...) (set ... "\\s-*$") (set ... ...) (set ... mode-require-final-newline) (make-local-variable ...) (set ... ...) (set ... ...) (add-hook ... ... nil t) (when ... ... ... ...) (set ... ...) (add-hook ... ... nil t) (add-hook ... py-complete-function nil ...) (set ... ...) (set ... py-indent-offset) (when py-smart-indentation ...) (when ... ...) (when py-load-pymacs-p ... ... ...) (define-key inferior-python-mode-map ... ...) (if py-menu ...) (when py-hide-show-minor-mode-p ...) (run-mode-hooks ...) (when py-start-run-py-shell ... ... ...) (when py-outline-minor-mode-p ...) (when ... ...)))
  (delay-mode-hooks (kill-all-local-variables) (setq major-mode (quote python-mode)) (setq mode-name "Python") nil (use-local-map python-mode-map) (set-syntax-table python-mode-syntax-table) (setq local-abbrev-table python-mode-abbrev-table) (set (make-local-variable ...) (quote ...)) (set (make-local-variable ...) t) (set (make-local-variable ...) t) (set (make-local-variable ...) "# ") (set (make-local-variable ...) "^[ ]*#+ *") (set (make-local-variable ...) 40) (set (make-local-variable ...) (function py-comment-indent-function)) (set (make-local-variable ...) (quote py-indent-region)) (set (make-local-variable ...) (quote py-indent-line)) (add-to-list (quote hs-special-modes-alist) (list ... ... nil "#" ... nil)) (set (make-local-variable ...) ":\\s-*\n") (set (make-local-variable ...) (function python-outline-level)) (set (make-local-variable ...) nil) (set (make-local-variable ...) (concat ... ...)) (set (make-local-variable ...) (quote py-current-defun)) (set (make-local-variable ...) "\\s-*$") (set (make-local-variable ...) (quote py-fill-paragraph)) (set (make-local-variable ...) mode-require-final-newline) (make-local-variable (quote python-saved-check-command)) (set (make-local-variable ...) (quote py-beginning-of-def-or-class)) (set (make-local-variable ...) (quote py-end-of-def-or-class)) (add-hook (quote which-func-functions) (quote python-which-func) nil t) (when (and imenu-create-index-p ...) (setq imenu-create-index-function ...) (setq imenu-generic-expression py-imenu-generic-expression) (when ... ... ...)) (set (make-local-variable ...) (function python-eldoc-function)) (add-hook (quote eldoc-mode-hook) (lambda nil ...) nil t) (add-hook (quote completion-at-point-functions) py-complete-function nil (quote local)) (set (make-local-variable ...) (quote ...)) (set (make-local-variable ...) py-indent-offset) (when py-smart-indentation (if ... ... ...)) (when (null py-shell-name) (py-toggle-shells ...)) (when py-load-pymacs-p (py-load-pymacs) (unwind-protect ...) (kill-buffer "pycomplete.el")) (define-key inferior-python-mode-map (kbd "<tab>") (quote python-shell-completion-complete-or-indent)) (if py-menu (easy-menu-add py-menu)) (when py-hide-show-minor-mode-p (hs-minor-mode 1)) (run-mode-hooks (if python-mode-hook ... ...)) (when py-start-run-py-shell (window-configuration-to-register 213465879) (unless ... ...) (jump-to-register 213465879)) (when py-outline-minor-mode-p (outline-minor-mode 1)) (when (interactive-p) (message "python-mode loaded from: %s" "python-mode.el")))
  python-mode()
  funcall(python-mode)
  (progn (funcall mode) mode)
  (if mode (progn (funcall mode) mode))
  (when mode (funcall mode) mode)
  (if (and keep-mode-if-same (eq ... ...)) nil (when mode (funcall mode) mode))
  (unless (and keep-mode-if-same (eq ... ...)) (when mode (funcall mode) mode))
  set-auto-mode-0(python-mode nil)
  set-auto-mode()
  (progn (set-auto-mode))
  (if debug-on-error (progn (set-auto-mode)) (condition-case err (progn ...) (error ...)))
  (report-errors "File mode specification error: %s" (set-auto-mode))
  (let ((enable-local-variables ...)) (report-errors "File mode specification error: %s" (set-auto-mode)) (report-errors "File local-variables error: %s" (hack-local-variables)))
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Pymacs.py> "~/entretien/pymacs/Pymacs.py" nil nil "~/entretien/pymacs/Pymacs.py" (402705 2053))
  find-file-noselect("Pymacs.py" nil nil nil)
  find-file("Pymacs.py" nil)
  find-alternate-file("Pymacs.py")
  ido-file-internal(alt-file find-alternate-file nil "Find alternate file: ")
  ido-find-alternate-file()
  call-interactively(ido-find-alternate-file nil nil)

I would seem that PYTHONPATH ought to be defined in the environment? I
do not see why it should. Checking both README and INSTALL (by the way,
that's really one too much, given the smallish size of these files!), I
see nothing to that effect.

While looking at this problem, may I suggest that you fetch the latest
Pymacs.py and pymacs.el from the Pymacs site and use those, getting rid
of the Pymacs directory? I made this simplification especially to ease
(or start easing!) packaging in python-mode.

François

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

Hi François,

can't reproduce that kind of error.
Maybe send the output of M-x report-emacs-bug, should it still happen.

As for the PYTHONPATH mentioned, don't see it's related to the error messages shown.

Fetched your latest Pymacs files, thanks. Unfortunately with new pymacs.el get the error "Pymacs didn't start...".
So won't change the tweaked inline Pymacs for the moment as it seems to work.

Should we get some Pymacs related bug report, being able to reproduce, that will change it...

So far,

Andreas

Changed in python-mode:
status: New → Incomplete
Revision history for this message
François Pinard (fpinard) wrote : Re: [Bug 929025] Re: opening Pymacs.py fails

Andreas Roehler <email address hidden> writes:

> Hi François,

Hello, Andreas.

> can't reproduce that kind of error. Maybe send the output of M-x
> report-emacs-bug, should it still happen.

OK, I'll do that, the next time I have some free time ahead and
reactivate python-mode to test it.

> As for the PYTHONPATH mentioned, don't see it's related to the error
> messages shown.

Sorry, I thought the traceback would have been sufficient. Let me try
to share more comments on it.

  Debugger entered--Lisp error: (wrong-type-argument stringp nil)
    string-match("/home/pinard/bureautique/emacs/_/python-mode/Pymacs"
    nil)

The second argument to string-match is nil, while it should be a
string. This comes from the beginning of function py-load-pymacs, which
reads:

  (let* ((pyshell (py-choose-shell))
         (path (getenv "PYTHONPATH"))
         (pymacs-installed-p
          (string-match (expand-file-name (concat py-install-directory "/Pymacs")) path)))

You see, that "nil" comes from the value of "path", which is computed
the line before as the value of "PYTHONPATH" in the environment. A
"nil" value means that "PYTHONPATH" is not defined in the environment.
So the bug is just in front of our eyes.

When you say you cannot reproduce the problem, did you unset
"PYTHONPATH" from your environment, prior to calling py-load-pymacs?

> Fetched your latest Pymacs files, thanks. Unfortunately with new
> pymacs.el get the error "Pymacs didn't start...". So won't change the
> tweaked inline Pymacs for the moment as it seems to work.

Does "make check" on the latest Pymacs works for you? If it does, but
does not work once within Python mode, the integration may be fishy.

> Should we get some Pymacs related bug report, being able to reproduce,
> that will change it...

You should not ought to tweak Pymacs. Untweak it (or just use the
recent one). If it does not work for you once you integrate it within
Python mode, you have your bug reproduced -- then make yourself a report
if you feel like it :-). If the bug is on the Pymacs side, I'll happily
correct it here, of course. Just email to me, and we will manage! :-)

It seems that going through run-python, PYTHONPATH is altered, so Pymacs
would likely work in there. (Yet, the code does not pay attention to
avoid doubling values along PYTHONPATH, which is an inefficiency.)
Maybe that some similar alteration might be used within py-load-pymacs?

François

Revision history for this message
François Pinard (fpinard) wrote :

Andreas Roehler <email address hidden> writes:

> ** Changed in: python-mode
> Status: New => Incomplete

[followed by a long repeat of the original problem]

Trackers at their best! (or worse! depending on if you feel ironic or
objective)

What is "Incomplete"?

* The description of the problem? It was surely complete enough to
  analyze the bug and develop a repair for it.

* The usage of the issue tracker? The tool then becomes a goal in
  itself, rather than the mean it was originally supposed to be.

* The impetus or will to repair the problem? Maybe, but then, this kind
  of subtlety is way beyond what the tracker may handle.

François

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

checked in a fix, can you try again?

thanks,

Andreas

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.5
importance: Undecided → Medium
Changed in python-mode:
status: New → Fix Committed
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.