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

Prevent crashing from UnicodeDecodeError #988

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Mar 23, 2016

  1. Prevent crashing from UnicodeDecodeError

    On Python 2, `sys.stdout` and `print` can normally handle any
    combination of `str` and `unicode` objects. However,
    `StringIO.StringIO` can only safely handle one or the other. If
    the program writes both a `unicode` string, and a non-ASCII
    `str` string, then the `getvalue()` method will fail with
    `UnicodeDecodeError` [1].
    
    In nose, that causes the script to suddenly abort, with the
    cryptic `UnicodeDecodeError`.
    
    This fix catches `UnicodeError` when trying to get the captured
    output, and will replace the captured output with a warning
    message.
    
    Fixes nose-devs#816
    
    [1] <https://github.com/python/cpython/blob/2.7/Lib/StringIO.py#L258>
    jmoldow committed Mar 23, 2016
    Configuration menu
    Copy the full SHA
    4501ab4 View commit details
    Browse the repository at this point in the history