An Emacs mode for editing Python code

Wrong type argument: number-or-marker-p, nil

Reported by MATSUI Tetsushi on 2011-12-08
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

Since I have switched to python-mode 6, I sometimes encounter the error "Wrong type argument: number-or-marker-p, nil". I could not break it down to minimize the case (and I don't like to open my secret code :) It should be related to indentation, since when it happens I always see the cursor is on column 0 of a new line and no longer TAB works.

Traceback:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  py-compute-indentation()
  py-newline-and-indent()
  call-interactively(py-newline-and-indent nil nil)

I know this report is too vague, sorry.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.4
importance: Undecided → Medium
Andreas Roehler (a-roehler) wrote :

Hi,

can't reproduce at the moment.

May you send the output from M-x report-emacs-bug, in case you encounter that next time?

Thanks,

Andreas

Changed in python-mode:
status: New → Incomplete
MATSUI Tetsushi (mft) wrote :

The attachment is the main part of the bug report text produced by M-x report-emacs-bug after a wrong type argument error. I hope this helps.

Changed in python-mode:
status: Incomplete → New

I am observing the same problem. Attached is the output of report-emacs-bug.

need some code example, which triggers the bug.

thanks,

Andreas

MATSUI Tetsushi (mft) wrote :

Today, when editing the attachment file, I encountered the error on the end of the first class MatrixData.
On the line just after the end of the class definition, hit TAB. This is reproducible on my emacs.

Andreas Roehler (a-roehler) wrote :

Am 19.12.2011 07:32, schrieb MATSUI Tetsushi:
> Today, when editing the attachment file, I encountered the error on the end of the first class MatrixData.
> On the line just after the end of the class definition, hit TAB. This is reproducible on my emacs.
>
> ** Attachment added: "a file that I encounter the error"
> https://bugs.launchpad.net/python-mode/+bug/901541/+attachment/2639180/+files/container_abc.py
>

hmm, TAB from pos 2348 circles here between 0 and 4, which seems correct.

could you do M-x report-emacs-bug
with this?

MATSUI Tetsushi (mft) wrote :
MATSUI Tetsushi (mft) wrote :

I can reproduce the error also with argparse.py of Python 2.7.2, and with python-mode 6.0.3. After opening the file, hit several C-v's until the cursor enters in a class, then hit TAB. Then the error occurs.
The exact position was not the point; in also #7, I used only C-v and <down> to move cursor. If I use C-u C-M-e to move to the end of the class, the error does not occur.

Andreas Roehler (a-roehler) wrote :

Am 20.12.2011 10:45, schrieb MATSUI Tetsushi:
> I can reproduce the error also with argparse.py of Python 2.7.2, and with python-mode 6.0.3. After opening the file, hit several C-v's until the cursor enters in a class, then hit TAB. Then the error occurs.
> The exact position was not the point; in also #7, I used only C-v and<down> to move cursor. If I use C-u C-M-e to move to the end of the class, the error does not occur.
>

can you send the positions as C-x C-= tells?

MATSUI Tetsushi (mft) wrote :

The result of C-x = on the line where I reproduce the bug:

Char: SPC (32, #o40, #x20) point=4220 of 87802 (5%) column=0

# C-x C-= is bound to text-style-adjust, which seems irrelevant

Can't you reproduce it still?

Andreas Roehler (a-roehler) wrote :

file from your attachment here has only

point=3846 of 3845 (EOB) column=0

it's called

container_abc.py

MATSUI Tetsushi (mft) wrote :

I meant argparse.py in #10 because you are commenting in #9 about my comment #8 which is a report about argparse.py.

Andreas Roehler (a-roehler) wrote :

Am 20.12.2011 16:38, schrieb MATSUI Tetsushi:
> I meant argparse.py in #10 because you are commenting in #9 about my
> comment #8 which is a report about argparse.py.
>

hmm, Emacs even hangs here with this. Thanks, I'm on it.

Changed in python-mode:
status: New → In Progress
Andreas Roehler (a-roehler) wrote :

does it still occur with last commit -r748 ?

MATSUI Tetsushi (mft) wrote :

No, it doesn't occur for both container_abc.py and argparse.py.

Changed in python-mode:
status: In Progress → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
MATSUI Tetsushi (mft) wrote :

Though previously reported files do not produce the error (as I said in #15), I am still experiencing this.
I attach the result of report-emacs-bug after the error in ast.py in the Python Library.

MATSUI Tetsushi (mft) wrote :

I had to add more info.

The version is revision 756 of bzr repository.

If you need, the result of C-x = is:
Char: SPC (32, #o40, #x20) point=10561 of 11805 (89%) column=0

Georg Brandl (gbrandl) on 2012-01-02
Changed in python-mode:
status: Fix Released → In Progress
Georg Brandl (gbrandl) wrote :
Download full text (51.1 KiB)

I'm also seeing this when pressing RET in a docstring. This is a debug trace:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  <(nil 6633)
  (if (< (nth 2 (if (featurep (quote xemacs)) (parse-partial-sexp (point-min) (point)) (syntax-ppss))) (line-beginning-position)) (current-indentation) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat))
  (progn (forward-line -1) (end-of-line) (skip-chars-backward "
\n\f") (if (< (nth 2 (if (featurep (quote xemacs)) (parse-partial-sexp (point-min) (point)) (syntax-ppss))) (line-beginning-position)) (current-indentation) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat)))
  (if (eq origline (py-count-lines)) (progn (forward-line -1) (end-of-line) (skip-chars-backward "
\n\f") (if (< (nth 2 (if (featurep (quote xemacs)) (parse-partial-sexp (point-min) (point)) (syntax-ppss))) (line-beginning-position)) (current-indentation) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat))) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat))
  (cond ((and (bobp) (eq origline (py-count-lines))) (current-indentation)) ((and (bobp) (py-statement-opens-block-p)) (+ (if py-smart-indentation (py-guess-indent-offset nil orig) py-indent-offset) (current-indentation))) ((and (bobp) (not (py-statement-opens-block-p))) (current-indentation)) ((and (nth 3 pps) (nth 8 pps)) (if (eq origline (py-count-lines)) (progn (forward-line -1) (end-of-line) (skip-chars-backward "
\n\f") (if (< (nth 2 (if ... ... ...)) (line-beginning-position)) (current-indentation) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat))) (ignore-errors (goto-char (nth 2 pps))) (py-line-backward-maybe) (back-to-indentation) (py-compute-indentation orig origline closing line inside repeat))) ((and (looking-at "\"\"\"\\|'''") (not (bobp))) (py-beginning-of-statement) (py-compute-indentation orig origline closing line inside repeat)) ((nth 8 pps) (if (eq origline (py-count-lines)) (progn (goto-char (nth 8 pps)) (py-line-backward-maybe) (skip-chars-backward " ") (py-compute-indentation orig origline closing line inside repeat)) (goto-char (nth 8 pps)) (if (and line (or py-indent-honors-inline-comment (looking-back "^[ ]*"))) (current-column) (forward-char -1) (py-compute-indentation orig origline closing line inside repeat)))) ((and (looking-at "[ ]*#") (looking-back "^[ ]*") (not (eq (line-beginning-position) (point-min)))) (forward-line -1) (end-of-line) (setq line t) (py-compute-indentation orig origline closing line inside repeat)) ((nth 1 pps) (cond ((and inside (not line)) (when (and (eq (point) orig) (looking-at "[ ]*\\()\\)[ ]*$")) (setq closing (match-beginning 0))) (save-excursion (goto-char (nth 1 pps)) (setq this-li...

Changed in python-mode:
milestone: 6.0.4 → 6.0.5
Andreas Roehler (a-roehler) wrote :

Am 02.01.2012 14:50, schrieb Georg Brandl:
> I'm also seeing this when pressing RET in a docstring. This is a debug
> trace:

get the error it from pos 316, inside tqs, thanks

Andreas Roehler (a-roehler) wrote :

please re-open, if the bug still exists

Changed in python-mode:
status: In Progress → Fix Committed
Georg Brandl (gbrandl) wrote :

Fixed it for my case, thanks!

MATSUI Tetsushi (mft) wrote :

Error doesn't occur for me now, thanks.

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

Other bug subscribers