emacs python-mode questions: C-c C-c and broken docstring fill

J

John J. Lee

1. Why do I get this in my minibuffer when I do C-c C-c in a
python-mode buffer containing the following valid Python code?

Wrong type argument: sequencep, cpython

----START
#!/usr/bin/env python

print "hello, world"
----END


2. A while ago I 'upgraded' to a version of python-mode (from
somewhere on sourceforge, I think -- perhaps Python CVS, don't
remember) which somebody here claimed was able to fill comments
without needing blank lines before and after the comment. It does do
that, but the new version also breaks filling text in docstrings
(under particular circumstances which I haven't figured out, but which
occurs very frequently). I get something like: "The parameter start
is not the beginning of a python string". Where does the latest
python-mode live, and is this fill bug with docstrings fixed?


John
 
S

Skip Montanaro

John> 1. Why do I get this in my minibuffer when I do C-c C-c in a
John> python-mode buffer containing the following valid Python code?

John> Wrong type argument: sequencep, cpython

It looks like a bug in py-execute-region. It sets the shell variable like
so:

(setq shell (or (py-choose-shell-by-shebang)
(py-choose-shell-by-import)
py-which-shell))))

which gives it the value (quote cpython). Later on it tries to concatenate
it:

(let ((cmd (concat shell (if (string-equal py-which-bufname "JPython")
" -" ""))))

which fails because shell is not a string (strictly speaking, a sequence) at
that point. I'm not sure what the correct fix is.

John> 2. A while ago I 'upgraded' to a version of python-mode (from
John> somewhere on sourceforge, I think -- perhaps Python CVS, don't
John> remember) which somebody here claimed was able to fill comments
John> without needing blank lines before and after the comment. It does
John> do that, but the new version also breaks filling text in
John> docstrings (under particular circumstances which I haven't figured
John> out, but which occurs very frequently). I get something like:
John> "The parameter start is not the beginning of a python string".
John> Where does the latest python-mode live, and is this fill bug with
John> docstrings fixed?

Can you file a bug report with a small failing example? Assign it to me
(montanaro).

Skip
 
S

Skip Montanaro

John> Wrong type argument: sequencep, cpython

Where the comment says "TBD: a horrible hack...": try replacing the
beginning of the let with

(let ((cmd (concat (if (eq shell (quote cpython))
"python"
"jython")
(if (string-equal py-which-bufname "JPython")
" -" ""))))

I have no idea what the "jython" string really should be. That was just a
guess.

Skip
 
J

John J. Lee

[...]
John> do that, but the new version also breaks filling text in
John> docstrings (under particular circumstances which I haven't figured
John> out, but which occurs very frequently). I get something like:
John> "The parameter start is not the beginning of a python string".
John> Where does the latest python-mode live, and is this fill bug with
John> docstrings fixed?

Can you file a bug report with a small failing example? Assign it to me
(montanaro).

OK, will try to do tomorrow.


John
 
J

John J. Lee

Skip Montanaro said:
John> Wrong type argument: sequencep, cpython

Where the comment says "TBD: a horrible hack...": try replacing the
beginning of the let with

(let ((cmd (concat (if (eq shell (quote cpython))
"python"
"jython")
(if (string-equal py-which-bufname "JPython")
" -" ""))))
[...]

That works. Thanks.


John
 
B

Bernhard Herzog

2. A while ago I 'upgraded' to a version of python-mode (from
somewhere on sourceforge, I think -- perhaps Python CVS, don't
remember) which somebody here claimed was able to fill comments
without needing blank lines before and after the comment. It does do
that, but the new version also breaks filling text in docstrings
(under particular circumstances which I haven't figured out, but which
occurs very frequently). I get something like: "The parameter start
is not the beginning of a python string". Where does the latest
python-mode live, and is this fill bug with docstrings fixed?

One situation where this can happen is if point is the at the @ in the
following triple quoted string:

"""nobody expects the "spanish" @inquision"""

The following patch should fix this I think (I haven't tested this very
well though):

*** python-mode.el.~4.35.~ Sat Jul 19 17:28:04 2003
--- python-mode.el Mon Jul 28 12:25:04 2003
***************
*** 3714,3720 ****
(py-fill-comment justify))
;; are we inside a string?
((nth 3 pps)
! (py-fill-string (nth 2 pps)))
;; otherwise use the default
(t
(fill-paragraph justify)))))
--- 3714,3720 ----
(py-fill-comment justify))
;; are we inside a string?
((nth 3 pps)
! (py-fill-string (nth 8 pps)))
;; otherwise use the default
(t
(fill-paragraph justify)))))


Bernhard
 
J

John J. Lee

Bernhard Herzog said:
One situation where this can happen is if point is the at the @ in the
following triple quoted string:

"""nobody expects the "spanish" @inquision"""

The following patch should fix this I think (I haven't tested this very
well though):
[...]

Works for me. Thanks. I'll post this with the bug report I'm just
about to file.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top