﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20445	BaseCommand --traceback should raise the original Exception	jorgebastida	jorgebastida	"When you are debugging long-running process that take hours to finish is really helpful to run them using {{{ ipython --pdb  <script> }}} so in case of failure, you'll get a ipdb trace just before the Exception was raised, so you can check what was wrong and fix it instead of adding an {{{ipdb}}} and re running the script.

As for the last weeks I've been writing some django command that takes hours to run I tried to run these scripts using {{{ ipython --pdb manage.py <command>}}} but unfortunately I found that {{{BaseCommand.run_from_argv}}} was capturing any Exception raised by my command and printing the traceback to {{{stderr}}} if the {{{--traceback}}} option was present, or name and error if not.

In order to use {{{ipython --pdb}}} I need to override {{{ run_from_argv}}}  In my commands and basically don't try/except {{{self.execute(*args, **options.__dict__)}}} what is pretty hacky.

After talking with Russell Keith-Magee we found that, as python default behavior is to print the traceback into {{{stderr}} and return an error status code when an Exception is raised and not captured, the solution would probably be to {{{raise}}} the Exception if {{{--traceback}}} is present. The consequences are:

a) The existing behavior doesn't change.
b) We can call {{{manage.py}}} commands from interpreters that do fancy things when exceptions are raised.

I haven't found anything related in the ""Better Error Message"" wiki page: https://code.djangoproject.com/wiki/BetterErrorMessages"	Bug	closed	Core (Management commands)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
