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

Discussion in 'Python' started by John J. Lee, Jul 27, 2003.

  1. John J. Lee

    John J. Lee Guest

    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
    John J. Lee, Jul 27, 2003
    #1
    1. Advertising

  2. 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
    Skip Montanaro, Jul 27, 2003
    #2
    1. Advertising

  3. 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
    Skip Montanaro, Jul 27, 2003
    #3
  4. John J. Lee

    John J. Lee Guest

    Skip Montanaro <> writes:

    [...]
    > 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
    John J. Lee, Jul 28, 2003
    #4
  5. John J. Lee

    John J. Lee Guest

    Skip Montanaro <> writes:

    > 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
    John J. Lee, Jul 28, 2003
    #5
  6. (John J. Lee) writes:

    > 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

    --
    Intevation GmbH http://intevation.de/
    Sketch http://sketch.sourceforge.net/
    Thuban http://thuban.intevation.org/
    Bernhard Herzog, Jul 28, 2003
    #6
  7. John J. Lee

    John J. Lee Guest

    Bernhard Herzog <> writes:
    [...about failure to fill...]
    > 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
    John J. Lee, Jul 29, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    455
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    444
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    502
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    415
    Edward Loper
    Aug 9, 2007
  5. bdb112
    Replies:
    3
    Views:
    252
    Chris Rebert
    Mar 9, 2009
Loading...

Share This Page