Ticket #23133: basecommand_check_stderr.diff

File basecommand_check_stderr.diff, 881 bytes (added by cpbotha, 10 years ago)
  • django/core/management/base.py

    diff --git a/django/core/management/base.py b/django/core/management/base.py
    index 2f8664f..3419595 100644
    a b class BaseCommand(object):  
    487487        if any(e.is_serious() and not e.is_silenced() for e in all_issues):
    488488            raise CommandError(msg)
    489489        elif msg and visible_issue_count:
    490             self.stderr.write(msg)
     490            # self.stderr is not guaranteed to be set here
     491            stderr = getattr(self, 'stderr', OutputWrapper(sys.stderr, self.style.ERROR))
     492            stderr.write(msg)
     493
    491494        elif msg:
    492             self.stdout.write(msg)
     495            # self.stdout is not guaranteed to be set here
     496            stdout = getattr(self, 'stdout', OutputWrapper(sys.stdout))
     497            stdout.write(msg)
    493498
    494499    def handle(self, *args, **options):
    495500        """
Back to Top