 						    nil
 						    file t))))))
     (pop-to-buffer buffer)
+    ;; Force Python mode
+    (if (not (eq major-mode) 'python-mode)
+	(python-mode))
     (goto-line line)
     (message "Jumping to exception in file %s on line %d" file line)))
 


(defun py-jump-to-exception (file line)
  (let ((buffer (cond ((string-equal file "<stdin>")
		       py-exception-buffer)
		      ((and (consp py-exception-buffer)
			    (string-equal file (car py-exception-buffer)))
		       (cdr py-exception-buffer))

  (switch-to-buffer-other-window
   (apply 'make-comint py-which-bufname py-which-shell nil py-which-args))
  (make-local-variable 'comint-prompt-regexp)
  (setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ")
  (set-process-filter (get-buffer-process (current-buffer)) 'py-process-filter)
  (set-syntax-table py-mode-syntax-table)
  ;; set up keybindings for this subshell
