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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user