def format_subject(self, subject):
        formatted_subject = subject.replace('\n', '\\n').replace('\r', '\\r')
        return formatted_subject[:989]
Escape CR and LF characters, and limit length.
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/utils/log.py/AdminEmailHandler.format_subject