Skip to content
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

log: Fix color logging detection #2019

Merged
merged 1 commit into from
Apr 20, 2017
Merged

Conversation

bdarnell
Copy link
Member

The previous logic would fail whenever curses is missing (which is
always true on windows, and is occasionally true on other platforms)
and colorama is installed but not initialized in this process (this is
a common occurrence for users of jupyter and ipython on windows).

Fixes #2013
Fixes #2015

cc @mivade

tornado/log.py Outdated
return color
return True
elif colorama:
if sys.stderr is getattr(colorama, 'wrapped_stderr', object()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will getattr(colorama, 'wrapped_stderr') ever work? It doesn't look at first glance that colorama/__init__.py contains wrapped_stderr: https://github.com/tartley/colorama/blob/master/colorama/__init__.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, doesn't look like it, but this is what you had in the previous PR. I'm trying to dust off a windows VM to test this. Looks like this will probably need to do a different check like you have in #2014. You've changed there from looking at colorama.initialize.wrapped_stderr to an isinstance check; do you have a particular reason to prefer one form over another? Neither appears to be documented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither appear to be documented, which is what makes me think that using isinstance (and failing gracefully when there is an AttributeError there) is somewhat better. It also makes it a bit easier to limit it only to Windows, which is the only time we would need to resort to colorama (or otherwise reimplement exactly what colorama already does).

Yes, what you have was in my previous PR. I honestly don't know how that got by. This is one reason I explicitly included the demo in #2014 so that it's at least possible to interactively test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Well, I'll go ahead and merge this so we can get a fix out the door, and see what happens with tartley/colorama#128.

The previous logic would fail whenever curses is missing (which is
always true on windows, and is occasionally true on other platforms)
and colorama is installed but not initialized in this process (this is
a common occurrence for users of jupyter and ipython on windows).

Fixes tornadoweb#2013
Fixes tornadoweb#2015
@bdarnell bdarnell merged commit ccf2e1e into tornadoweb:master Apr 20, 2017
@bdarnell bdarnell deleted the colorama-fix branch April 20, 2017 03:16
@mivade
Copy link
Contributor

mivade commented Apr 20, 2017

Were you able to run the demo in #2014 with this on the Windows VM? It would be good to double check that it doesn't still error.

@bdarnell
Copy link
Member Author

I didn't run the script from #2014 but I did some manual testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants