An Emacs mode for editing Python code

does not dedent regions/buffer all the way before 'exec'

Reported by Yaroslav Halchenko on 2012-10-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

kept hitting it whener current code block/region indentation level is more than just 4 spaces.

E.g. if I simply create a file with 8 spaces indented first line

        print "HELLO"

the resultant file exec to ipython is

#! /usr/bin/ipython

import os; os.chdir("/home/yoh/python-env")
    print "HELLO"

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → Medium
Changed in python-mode:
milestone: none → 6.1.0
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
Yaroslav Halchenko (yarikoptic) wrote :

I am trying rev 1127 -- problem is still there... just try to pipe a file with only an 8 spaces indented line like in my example above (you can easily get into such situations if you narrow to a region and want to pipe it)

Changed in python-mode:
status: Fix Committed → New

Am 01.11.2012 15:47, schrieb Yaroslav Halchenko:
> I am trying rev 1127 -- problem is still there... just try to pipe a
> file with only an 8 spaces indented line like in my example above (you
> can easily get into such situations if you narrow to a region and want
> to pipe it)
>

may you run the test with the resp. number from test/py-bug-numbered-tests.el
?

Does that work for you?

Yaroslav Halchenko (yarikoptic) wrote :
Download full text (4.5 KiB)

interesting ;)

so -- if I load-library and just invoke
does-not-dedent-regions-lp-1072869-test

it reports that it passes:

does-not-dedent-regions-lp-1072869-test passed

BUT then if I dig out and find *Python* buffer there I see plenty of (this one
is already modified by me to be (let ((teststring " print
\"HELLO\"\n")) but the same happens with original one):

Python 2.7.3 (default, Aug 26 2012, 11:57:48)
[GCC 4.7.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yoh/.tmp/python-22782Hwp.py", line 4
    print "HELLO"
    ^
IndentationError: unexpected indent
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yoh/.tmp/python-22782U6v.py", line 4
    print "HELLO"
    ^
IndentationError: unexpected indent
>>>

so I guess the "Tester" needs to be tuned up to catch those failures

also FWIW if I run all (py-bug-numbered-tests)

leads me to interactive debugger with

Debugger entered--Lisp error: (error "exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed")
  signal(error ("exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed"))
  error("exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed")
  (or (eq (get-char-property ... ...) (quote font-lock-keyword-face)) (error "exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed"))
  (progn (or (eq ... ...) (error "exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed")) nil)
  (assert (eq (get-char-property ... ...) (quote font-lock-keyword-face)) nil "exception-in-except-clause-highlighted-as-keyword-lp-909205-test #1 failed")
  exception-in-except-clause-highlighted-as-keyword-lp-909205-base()
  funcall(exception-in-except-clause-highlighted-as-keyword-lp-909205-base)
  (let ((debug-on-error t) (enable-local-variables :all) py-load-pymacs-p py-split-windows-on-execute-p py-shell-switch-buffers-on-execute-p py-start-run-py-shell proc py-fontify-shell-buffer-p) (if nil (find-file ...) (set-buffer ...)) (switch-to-buffer (current-buffer)) (delete-other-windows) (erase-buffer) (fundamental-mode) (insert teststring) (local-unset-key (kbd "RET")) (python-mode) (when (and ... company-mode) (company-abort)) (funcall (quote exception-in-except-clause-highlighted-as-keyword-lp-909205-base)) (message "%s" (replace-regexp-in-string "\\\\" "" ...)) (unless (< 1 arg) (set-buffer-modified-p ...) (and ... ... ...) (kill-buffer ...)))
  (py-bug-tests-intern (quote exception-in-except-clause-highlighted-as-keyword-lp-909205-base) arg teststring)
  (let ((teststring "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\ntry:\n blah\nexcept ormexc.NoResultFound:\n pass\n")) (py-bug-tests-intern (quote exception-in-except-clause-highlighted-as-keyword-lp-909205-base) arg teststring))
  exception-in-except-clause-highlighted-as-keyword-lp-909205-test(1)
  funcall(exception-in-except-clause-highlighted-as-keyword-lp-909205-test 1)
  (while --cl-dolist-temp-- (setq ele (car --cl-dolist-temp--)) (funcall ele arg) (setq --cl-dolist-temp-- (...

Read more...

Andreas Roehler (a-roehler) wrote :

checked in a fix, please try again

Changed in python-mode:
status: New → In Progress
Changed in python-mode:
status: In Progress → Fix Committed
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