New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when printing to console with special characters. #51
Comments
Without Honcho:
With Honcho:
|
Oh dear. That's not very good. Shouldn't be too hard to fix, I don't think. I'll take a look at the weekend. |
Great, thank you ! :) Another precision, running Honcho locally works fine for me. Honcho locally - > Fine Among others, I have those environment variables on Heroku:
|
Hi Nick, I also ran into the problem with some accentuated characters. Did you have time to look into that? Can we help somehow? |
Hi guys. Sorry I haven't had a chance to look at this yet. What would be really useful is a failing test case. If you feel up to it, a pull request with a test that demonstrates the failure consistently would be really useful. I imagine this will take the form of a script in |
I'm trying to write a test case that demonstrates the failure but it's not easy to do since it depends on the console encoding. From my local environement:
On Heroku, I just looked over the def emit(self, record):
"""
Emit a record.
If a formatter is specified, it is used to format the record.
The record is then written to the stream with a trailing newline. If
exception information is present, it is formatted using
traceback.print_exception and appended to the stream. If the stream
has an 'encoding' attribute, it is used to determine how to do the
output to the stream.
"""
try:
msg = self.format(record)
stream = self.stream
fs = "%s\n"
if not _unicode: #if no unicode support...
stream.write(fs % msg)
else:
try:
if (isinstance(msg, unicode) and
getattr(stream, 'encoding', None)):
ufs = fs.decode(stream.encoding)
try:
stream.write(ufs % msg)
except UnicodeEncodeError:
#Printing to terminals sometimes fails. For example,
#with an encoding of 'cp1251', the above write will
#work if written to a stream opened or wrapped by
#the codecs module, but fail when writing to a
#terminal even when the codepage is set to cp1251.
#An extra encoding step seems to be needed.
stream.write((ufs % msg).encode(stream.encoding))
else:
stream.write(fs % msg)
except UnicodeError:
stream.write(fs % msg.encode("UTF-8"))
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record) It looks a lot different in the actual source of python though : http://hg.python.org/cpython/file/ab05e7dd2788/Lib/logging Maybe we can get some inspiration from this. |
Any movement on this? |
I don't think Honcho is doing anything wrong here. The purpose of the If you want to fix this on Heroku, just set the
|
To be clear, if you run Honcho in a terminal with an appropriate |
Just in case anybody else runs into this: I had to export |
I'm experiencing crashes when Honcho tries to print to console with special characters:
Here is a Stackoverflow question with more details:
http://stackoverflow.com/questions/19100116/looks-like-logs-are-crashing-my-django-app
The text was updated successfully, but these errors were encountered: