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

Encoding problem? #451

Open
jpellerin opened this issue Dec 14, 2011 · 2 comments
Open

Encoding problem? #451

jpellerin opened this issue Dec 14, 2011 · 2 comments
Assignees

Comments

@jpellerin
Copy link
Member

What steps will reproduce the problem?
fetch https://bitbucket.org/dreamkxd/hgsubversion.svnmeta
install subvertpy on Windows, Python 2.7.1

https://bitbucket.org/dreamkxd/hgsubversion.svnmeta/downloads/subvertpy-0.8.8.win32-py2.7.exe

D:\CI\bld\hgsubversion.svnmeta\tests>nosetests --cover-html
............................................................................................................ETraceback (most recent call las
t):
File "D:\CI\Tools\Building\Python\Scripts\nosetests-script.py", line 9, in
load_entry_point('nose==1.1.2', 'console_scripts', 'nosetests')()
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\core.py", line 118, in init
*_extra_args)
File "D:\CI\Tools\Building\Python\lib\unittest\main.py", line 95, in init
self.runTests()
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\core.py", line 197, in runTests
result = self.testRunner.run(self.test)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\core.py", line 61, in run
test(result)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 176, in call
return self.run(_arg, *_kw)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 223, in run
test(orig)
File "D:\CI\Tools\Building\Python\lib\unittest\suite.py", line 65, in call
return self.run(_args, *_kwds)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 74, in run
test(result)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 176, in call
return self.run(_arg, *_kw)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 223, in run
test(orig)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 176, in call
return self.run(_arg, *_kw)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\suite.py", line 223, in run
test(orig)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\case.py", line 45, in call
return self.run(_arg, *_kwarg)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\case.py", line 138, in run
result.addError(self, err)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\proxy.py", line 131, in addError
formatted = plugins.formatError(self.test, err)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\plugins\manager.py", line 94, in call
return self.call(_arg, *_kw)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\plugins\manager.py", line 136, in chain
result = meth(_arg, **kw)
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\plugins\capture.py", line 73, in formatError
test.capturedOutput = output = self.buffer
File "D:\CI\Tools\Building\Python\lib\site-packages\nose\plugins\capture.py", line 125, in _get_buffer
return self._buf.getvalue()
File "D:\CI\Tools\Building\Python\lib\StringIO.py", line 270, in getvalue
self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

D:\CI\bld\hgsubversion.svnmeta\tests>nosetests
..
What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Google Code Info:
Issue #: 457
Author: [email protected]
Created On: 2011-10-16T17:03:52.000Z
Closed On:

@ghost ghost assigned jpellerin Dec 14, 2011
@Vido
Copy link

Vido commented Jun 26, 2013

I'm getting the same here.

I'm using Django1.3, Python 2.7.3, Win7x64
I can't tell the exact way how to reproduce this.

I managed to fix it by making a little workaround:
on nose\plugins\capture.py we have:

    def formatError(self, test, err):
        """Add captured output to error report.
        """
        test.capturedOutput = output = self.buffer
        self._buf = None
        if not output:
            # Don't return None as that will prevent other
            # formatters from formatting and remove earlier formatters
            # formats, instead return the err we got
            return err
        ec, ev, tb = err
        return (ec, self.addCaptureToErr(ev, output), tb)

We can write it like this:

    def formatError(self, test, err):
        """Add captured output to error report.
        """
        try:
            test.capturedOutput = output = self.buffer
        except UnicodeDecodeError:
            test.capturedOutput = output = 'FOOBAR'

        self._buf = None
        if not output:
            # Don't return None as that will prevent other
            # formatters from formatting and remove earlier formatters
            # formats, instead return the err we got
            return err
        ec, ev, tb = err
        return (ec, self.addCaptureToErr(ev, output), tb)

Is it ok to do that?
I don't know if this will crash nose if something goes wild. Neither if i'm making silent errors.

Traceback:

Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "c:\python27\lib\site-packages\django\core\management__init__.py", line 459, in execute_manager
utility.execute()
File "c:\python27\lib\site-packages\django\core\management__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\python27\lib\site-packages\django\core\management\commands\test.py", line 49, in run_from_argv
super(Command, self).run_from_argv(argv)
File "c:\python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "c:\python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(_args, *_options)
File "c:\python27\lib\site-packages\django\core\management\commands\test.py", line 72, in handle
failures = test_runner.run_tests(test_labels)
File "C:\TMP\Site\credit_diagnostic\django_nose\runner.py", line 194, in run_tests
result = self.run_suite(nose_argv)
File "C:\TMP\Site\credit_diagnostic\django_nose\runner.py", line 141, in run_suite
addplugins=plugins_to_add)
File "C:\TMP\Site\credit_diagnostic\nose\core.py", line 118, in init
*_extra_args)
File "c:\python27\lib\unittest\main.py", line 95, in init
self.runTests()
File "C:\TMP\Site\credit_diagnostic\nose\core.py", line 197, in runTests
result = self.testRunner.run(self.test)
File "C:\TMP\Site\credit_diagnostic\nose\core.py", line 61, in run
test(result)
File "C:\TMP\Site\credit_diagnostic\nose\suite.py", line 176, in call
return self.run(_arg, *_kw)
File "C:\TMP\Site\credit_diagnostic\nose\suite.py", line 223, in run
test(orig)
File "C:\TMP\Site\credit_diagnostic\nose\suite.py", line 176, in call
return self.run(_arg, *_kw)
File "C:\TMP\Site\credit_diagnostic\nose\suite.py", line 223, in run
test(orig)
File "C:\TMP\Site\credit_diagnostic\nose\case.py", line 45, in call
return self.run(_arg, *_kwarg)
File "C:\TMP\Site\credit_diagnostic\nose\case.py", line 138, in run
result.addError(self, err)
File "C:\TMP\Site\credit_diagnostic\nose\proxy.py", line 131, in addError
formatted = plugins.formatError(self.test, err)
File "C:\TMP\Site\credit_diagnostic\nose\plugins\manager.py", line 99, in call
return self.call(_arg, *_kw)
File "C:\TMP\Site\credit_diagnostic\nose\plugins\manager.py", line 141, in chain
result = meth(_arg, **kw)
File "C:\TMP\Site\credit_diagnostic\nose\plugins\capture.py", line 73, in formatError
test.capturedOutput = output = self.buffer
File "C:\TMP\Site\credit_diagnostic\nose\plugins\capture.py", line 126, in _get_buffer
return self._buf.getvalue()
File "c:\python27\lib\StringIO.py", line 271, in getvalue
self.buf += ''.join(self.buflist)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)

@gamesbook
Copy link

Patched in #988

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

No branches or pull requests

3 participants