diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-01-25 14:52:24 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-01-25 14:56:41 +0100 |
| commit | b9c8bbf3726a1956be1db70ffd3bef04a2e5311a (patch) | |
| tree | 4b07462ba19354e4c130342929fe595e3695b7d2 /django | |
| parent | eafc0364764ba12babd76194d8e1f78b876471ec (diff) | |
Fixed #19665 -- Ensured proper stderr output for Command.run_from_argv
Thanks Stefan Koegl for the report and Simon Charette for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/base.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py index 895753ea12..7b9001ed14 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -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): |
