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 failure in doctest error handling on py3/windows #540

Closed
pytestbot opened this issue Jul 14, 2014 · 2 comments
Closed

Encoding failure in doctest error handling on py3/windows #540

pytestbot opened this issue Jul 14, 2014 · 2 comments
Labels
platform: windows windows platform-specific problem plugin: doctests related to the doctests builtin plugin type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ionel Cristian Mărieș (BitBucket: ionelmc, GitHub: ionelmc)


I get this sort of failure:

C:\Users\ionel_000\Projects\asdfasdf>tox
py34 create: C:\Users\ionel_000\Projects\asdfasdf\.tox\py34
py34 installdeps: pytest
py34 runtests: PYTHONHASHSEED='922087378'
py34 runtests: commands[0] | py.test -vv
============================= test session starts =============================
platform win32 -- Python 3.4.1 -- py-1.4.20 -- pytest-2.5.2 -- C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\Scripts\python.exe
collected 1 items

unicode.rst: [doctest] unicode.rst
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 81, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 118, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 377, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 138, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 377, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 64, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 74, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 110, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 162, in call_matching_hooks
INTERNALERROR>     return hookmethod.pcall(plugins, **kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 381, in pcall
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\capture.py", line 246, in pytest_runtest_makereport
INTERNALERROR>     rep = __multicall__.execute()
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 208, in pytest_runtest_makereport
INTERNALERROR>     longrepr = item.repr_failure(excinfo)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\doctest.py", line 61, in repr_failure
INTERNALERROR>     filelines = py.path.local(filename).readlines(cr=0)
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\py\_path\common.py", line 134, in readlines
INTERNALERROR>     content = self.read('rU')
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\py\_path\common.py", line 126, in read
INTERNALERROR>     return f.read()
INTERNALERROR>   File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\encodings\cp1250.py", line 23, in decode
INTERNALERROR>     return codecs.charmap_decode(input,self.errors,decoding_table)[0]
INTERNALERROR> UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 8: character maps to <undefined>

==============================  in 0.05 seconds ===============================
ERROR: InvocationError: 'C:\\Users\\ionel_000\\Projects\\asdfasdf\\.tox\\py34\\Scripts\\py.test.EXE -vv'
___________________________________ summary ___________________________________
ERROR:   py34: commands failed

Testcase: https://gist.github.com/ionelmc/4a56e2467aeb6d228ebe

This fails because the unicode.rst file is utf8 while the windows' default encoding is some code page.

Also tested with tip from py/pytest - still reproduces. I've glossed over the code but the fix involves adding "encoding awareness" all over in the py module. What to do ?


@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
@pfctdayelise pfctdayelise added plugin: doctests related to the doctests builtin plugin platform: windows windows platform-specific problem unicode labels Jul 25, 2015
@decentral1se
Copy link
Contributor

Can this can be closed off since #2101 was merged?

@nicoddemus
Copy link
Member

Good call @lwm 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: windows windows platform-specific problem plugin: doctests related to the doctests builtin plugin type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants