Open hazzashirt opened 7 years ago
The problem here appears to be rooted in the environment. Specifically, the codepage of the console (terminal) is not utf-8.
I can't be 100% sure of this, since I do not have Windows 10, however see this SO answer for a similar situation. If you have Windows 10, feel free to try running chcp 65001
before running the test. If that makes the error go away, then I would feel fairly confident this is what's going on.
I have found some activity starting in August 2016 addressing this problem directly in Python: https://www.python.org/dev/peps/pep-0529/ http://bugs.python.org/issue1602 Could someone (who has seen this behavior in Windows) try updating Python to see if that resolves the error?
I looked for a way to change the parent terminal's encoding directly from python, however I saw no obvious solutions. It is possible that executing the chcp command from within python would resolve the problem, but that's a platform-dependent fix. I have no way of even testing that without Windows 10, and if there is a native Python way of getting the same effect, that would be preferable.
Note about non-Windows environments: The same type of behavior can occur on other platforms, however most use UTF-8 by default. I was able to cause a similar failure of the test in Ubuntu by creating a custom charset (CP850 in my case,) compiling a locale with it, and changing my LANG environment variable to reference the new locale/charset combo. The basic process is laid out in this SO answer, however they were making a custom locale and I was making a custom charset.
In Windows 10 64-bit: When running the test suite via the cmd (>setup.py test...) or via Cricket, test_str in all suites fails with the following error:
AssertionError: '>>> [321 chars]abs\n>>> x = "Mÿ hôvèrçràft îß fûłl öf éêlś"\n[319 chars]==\n' != '>>> [321 chars]abs\n<class \'UnicodeEncodeError\'> : \'charma[341 chars]==\n'
More details:
tests.builtins.test_any.BuiltinAnyFunctionTests.test_str