[Python-mode] python-mode errors with NTEmacs and python 2.3.3

Lucky Forumer luckyforumer at aemail4u.com
Sat Jun 5 05:50:29 EDT 2004


Having spent the better half of the day on this, I'm wondering how, if at all possible, one can get around SyntaxError messages in a python-mdoe interpreter that occur at the end of every line entered, for example:

Python 2.3.3 (#1, Apr 30 2004, 08:54:23) 
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 + 3
  File "<stdin>", line 1
    2 + 3
         ^
SyntaxError: invalid syntax
>>> 

This error is preventing me from using the Execute region, def/class functions also, as the SyntaxError is encountered after the execfile statement. Seems like something buggy is going on with comint-send-input...

Also, when attempting to use Execute buffer, I get "Lisp error: (wrong-type-argument sequencep cpython)" (backtrace at bottom)

My goal here is to get some form of debugging working under NTEmacs, I read at http://www.zopewiki.org/DebuggingWithEmacs someone was using pdbtrack from an interactive python shell, which would be swell.

I've tried just about everything I could come up with, including changing the buffer edit mode to dos, mac, and unix, changing the shell to cmdproxy from bash, a bunch of different combinations of comint-process-echoes, comint-eol-on-send, binary-process-input, and binary-process-ouput. Found a message on google groups, from 1998 or so, suggesting (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t) which doesn't do the trick, either.

This is actually the third time I've tried, but definitely the longest I've spent on it... really had some hope as it looks like python-mode development is alive again.

Environment is NTEmacs 21.3.1, Cygwin Python 2.3.3, python-mode 4.5.4, Windows XP. My .emacs in it's current state is attached, pertinent section probably starts at (setq cygnus "c:/cygwin/bin/")

Python runs fine from a normal bash or Windows command prompt.

Please help! Someone else must have some experience with this...

For what it's worth, the backtrace from Execute buffer:
Debugger entered--Lisp error: (wrong-type-argument sequencep cpython)
  concat(cpython "")
  (let ((cmd ...)) (save-excursion (set-buffer buf) (shell-command-on-region ... ... cmd py-output-buffer)) (if (not ...) (message "No output.") (setq py-exception-buffer ...) (let ... ... ...)))
  (cond (async (save-excursion ... ...) (let* ... ... ... ...)) (proc (save-excursion ... ...) (if ... ... ...) (setq py-file-queue ...) (setq py-exception-buffer ...)) (t (let ... ... ...)))
  (let* ((proc ...) (temp ...) (file ...) (cur ...) (buf ...) shell) (save-excursion (goto-char start) (beginning-of-line) (while ... ...) (setq start ...) (or ... ...) (let ... ... ... ... ... ...)) (cond (async ... ...) (proc ... ... ... ...) (t ...)) (kill-buffer buf))
  py-execute-region(1 15183 nil)
  py-execute-buffer(nil)
* call-interactively(py-execute-buffer)



_____________________________________________________________
**********************************************************
SMS(mobile text messages) around the world, 
Get 100 messages for $7.95, plus sign up now 
and get 2 free tryout messages http://sms.aemail4u.com
**********************************************************
-------------- next part --------------
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.

;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)

;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "C:/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "C:/emacs/site/elib"))
(add-to-list 'load-path (expand-file-name "C:/emacs/site/cedet-1.0beta1c"))
(add-to-list 'load-path (expand-file-name "C:/emacs/site"))

(add-to-list 'load-path (expand-file-name "C:/emacs/site/planner"))

;; Load CEDET
(load-file "C:/emacs/site/cedet-1.0beta1c/common/cedet.el")

;; Load planner
(require 'planner)
(setq mark-diary-entries-in-calendar t)

;; If you want Emacs to defer loading the JDE until you open a 
;; Java file, edit the following line
;;(setq defer-loading-jde nil)
;; to read:
;;
(setq defer-loading-jde t)
;;

(if defer-loading-jde
    (progn
      (autoload 'jde-mode "jde" "JDE mode." t)
      (setq auto-mode-alist
	    (append
	     '(("\\.java\\'" . jde-mode))
	     auto-mode-alist)))
  (require 'jde))


;; Turn on font locking in all modes that support it
(global-font-lock-mode 1)

;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
  (setq c-basic-offset 2))

(add-hook 'jde-mode-hook 'my-jde-mode-hook)

;; Uncomment the following for CUA/Windows style keybindings
;;(pc-selection-mode) 
;;(load "cua-mode")
;;(CUA-mode t)

;; Include the following only if you want to run
;; bash as your shell.

;; Begin move-to-window block:
;; This code is from the O'Reilly "GNU Emacs Extensions" book.
;; The purpose of it is to make a reasonable way to move to the next OR previous window.
;; Change from C-x o to C-x n, so that we have Next and Previous.  
(global-set-key "\C-xn" 'other-window) 

;; We must make our own function to go to the previous window (but it's simple):
(defun other-window-backward ()
  "Select the previous window."
  (interactive)
  (other-window -1))
;; Now we can bind to this function:
(global-set-key "\C-xp" 'other-window-backward)
;; End move to window block.

;; Setup Emacs to run bash as its primary shell.
(setq cygnus "c:/cygwin/bin/")
(defun my-shell-setup ()
  "For bash under Emacs 20"
  (setq comint-process-echoes nil)
  (setq comint-eol-on-send t)
  ;;(setq w32-quote-process-args ?\")
  ;(setq binary-process-input nil)
  ;(setq binary-process-ouput nil)
  )
(add-hook 'shell-mode-hook 'my-shell-setup)
;;; for the CRLF Problem
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)


;(setq process-coding-system-alist (cons '("bash" . raw-text-unix)
;                                        process-coding-system-alist))

;;; shell on win95 to bash
  ;(setenv "SHELL" (concat cygnus "bash.exe"))
  ;(setq shell-file-name (getenv "SHELL"))
  ;(setenv "COMSPEC" (concat cygnus "bash.exe"))


;;(setq shell-file-name "bash")
  ;(setq shell-command-switch "-c")
  ;(setq explicit-shell-file-name shell-file-name)
;;(setenv "SHELL" shell-file-name)
;;(setq explicit-sh-args '("--login" "-i"))
;;(if (boundp 'w32-quote-process-args)
;;  (setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
(let* ((cygwin-root "c:/cygwin")
       (cygwin-bin (concat cygwin-root "/bin")))
  (setenv "PATH" (concat cygwin-bin ";/usr/local/bin;/usr/bin;c:/users/God/bin;" (getenv "PATH")))
  (setq exec-path (cons "c:/users/God/bin" exec-path))
  (setq exec-path (cons cygwin-bin exec-path))
  (setq exec-path (cons "c:/cygwin/usr/bin" exec-path))
  (setq exec-path (cons "c:/cygwin/usr/local/bin" exec-path)))




;; Verilog-mode additions 4/2/03
;;(defun prepend-path ( my-path )
;;(setq load-path (cons (expand-file-name my-path) load-path)))
	  
;;(defun append-path ( my-path )
;;(setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the directory ~/elisp for elisp files
;;(prepend-path "C:/emacs/site/")

;; Stuff for Verilog mode
;;
(add-to-list 'load-path (expand-file-name "C:/emacs/site/verilog"))
;; Load verilog mode only when needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
;; Any files that end in .v should be in verilog mode
(setq auto-mode-alist (cons  '("\\.v\\'" . verilog-mode) auto-mode-alist))
;; Any files in verilog mode should have their keywords colorized
;;(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))


;; change defaults to make them kinder on the eyes
;; (set-background-color "black")
;; (set-foreground-color "white")
;; (set-cursor-color "White")
;; (custom-set-variables
;;  '(global-font-lock-mode t nil (font-lock))
;;  (custom-set-faces
;;   '(font-lock-default-face ((t (:foreground "White" :background "Black"))))
;;   '(font-lock-comment-face ((t (:foreground "Yellow" :background "Black"))))
;;   '(font-lock-string-face ((t (:foreground "LimeGreen" :background "Black"))))
;;   '(font-lock-keyword-face ((t (:foreground "Gold" :background "Black"))))
;;   '(font-lock-warning-face ((t (:foreground "White" :background "Firebrick"))))
;;   '(font-lock-constant-face ((t (:foreground "LightGray" :background "Black"))))
;;   '(font-lock-type-face ((t (:foreground "Red" :background "Black"))))
;;   '(font-lock-variable-name-face ((t (:foreground "Black" :background "SteelBlue"))))
;;   '(font-lock-function-name-face ((t (:foreground "Black" :background "White"))))
;;   '(font-lock-builtin-face ((t (:foreground "Black" :background "ForestGreen"))))))

;; Maximum colors
(setq font-lock-maximum-decoration t)
;; hitting delete will delete the highlighted region
(pending-delete-mode 1)
;; Stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)
;; add column position to mode line
(setq column-number-mode t)
;; truncate-partial-width-windows is related to line-wrapping
;; as is truncate-lines (defaults to nil)
(set-default 'truncate-partial-width-windows nil)
 
;; Color Themes package! http://www.emacswiki.org/cgi-bin/wiki.pl?ColorTheme
;; Usage: M-x color-theme-select RET
;; Use the `?' in the Color Theme Selection buffer to find the name of the appropriate color theme function
(require 'color-theme)
(color-theme-ld-dark)
;;(color-theme-robin-hood)


;; Add mode for editing DOS bat and cmd files
;; removed because it was breaking lines at ~64 chars
;;(add-to-list 'load-path (expand-file-name "C:/emacs/site/bat-mode"))
;;; `site-start.el' file and put bat-mode.el somewhere on your
;;; load-path to take advantage of bat-mode.
;;(autoload 'bat-mode "bat-mode" "bat-mode Editing Mode" t)
;;(setq auto-mode-alist
;;      (append '(("\\.bat\\b"  . bat-mode))
;;	      auto-mode-alist))
;;(add-hook 'bat-mode-hook 'turn-on-font-lock)
;;; You may also want to byte-compile bat-mode.el to improve performance.
;;; Try evaluating the following form:
;;; (byte-compile-file (locate-library "bat-mode.el"))


;; Add css-mode 
(autoload 'css-mode "css-mode")
(setq auto-mode-alist       
     (cons '("\\.css\\'" . css-mode) auto-mode-alist))
(setq cssm-indent-function #'cssm-c-style-indenter)

;; Add Python mode
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode)
            interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
(add-hook 'python-mode-hook
           (lambda ()
             (set (make-variable-buffer-local 'beginning-of-defun-function)
                  'py-beginning-of-def-or-class)
             (setq outline-regexp "def\\|class ")))


;; SQL mode
;; make postgres keyword higlighting the default
(eval-after-load "sql-mode"
  '(add-hook 'sql-mode-hook (lambda ()
			      (sql-highlight-postgres-keywords))))


(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "Latin-1")
 '(debug-on-error t)
 '(default-input-method "latin-1-prefix")
 '(global-font-lock-mode t nil (font-lock))
 '(jde-compiler (quote ("javac" "c:\\j2sdk1.4\\bin\\javac")))
 '(py-python-command "python2.3.exe")
 '(show-paren-mode t nil (paren))
 '(sql-postgres-options (quote ("-P" "pager=off" "-Upostgres" "-W")))
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(transient-mark-mode nil)
 '(uniquify-buffer-name-style (quote forward) nil (uniquify)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )


More information about the Python-mode mailing list