1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

Fixed #19665 -- Ensured proper stderr output for Command.run_from_argv

Thanks Stefan Koegl for the report and Simon Charette for the review.
This commit is contained in:
Claude Paroz
2013-01-25 14:52:24 +01:00
parent eafc036476
commit b9c8bbf372
2 changed files with 32 additions and 2 deletions

View File

@@ -221,9 +221,12 @@ class BaseCommand(object):
try:
self.execute(*args, **options.__dict__)
except Exception as e:
# self.stderr is not guaranteed to be set here
stderr = getattr(self, 'stderr', OutputWrapper(sys.stderr, self.style.ERROR))
if options.traceback:
self.stderr.write(traceback.format_exc())
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
stderr.write(traceback.format_exc())
else:
stderr.write('%s: %s' % (e.__class__.__name__, e))
sys.exit(1)
def execute(self, *args, **options):