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
android: test_sys fails #71107
Comments
test_sys fails on an android emulator running an x86 system image at API level 21. ...
test_implementation (test.test_sys.SysModuleTest) ... ok
test_intern (test.test_sys.SysModuleTest) ... ok
test_ioencoding (test.test_sys.SysModuleTest) ... ok
test_ioencoding_nonascii (test.test_sys.SysModuleTest) ... Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xe6' in position 0: ordinal not in range(
128)
FAIL
test_is_finalizing (test.test_sys.SysModuleTest) ... ok
test_lost_displayhook (test.test_sys.SysModuleTest) ... ok
... ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_sys.py", line 709, in test_c_locale_surr
ogateescape
'stdin: surrogateescape\n'
AssertionError: 'stdin: strict\nstdout: strict\nstderr: backslashreplace\n' != 'stdin: surrogateesca
pe\nstdout: surrogateescape\nstderr: backslashreplace\n'
- stdin: strict
- stdout: strict
+ stdin: surrogateescape
+ stdout: surrogateescape
stderr: backslashreplace ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_sys.py", line 638, in test_ioencoding_no
nascii
self.assertEqual(out, os.fsencode(test.support.FS_NONASCII))
AssertionError: b'' != b'\xc3\xa6' Ran 43 tests in 0.913s FAILED (failures=2, skipped=2) |
test_ioencoding_nonascii does not fail when LANG is set to en_GB.UTF-8 in the environment. |
When LANG is not set, we have on an android emulator: >>> from test.support import FS_NONASCII
>>> print(FS_NONASCII)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xe6' in position 0: ordinal not in range(128) But on linux when LANG is not set: $ LANG= ./python
Python 3.6.0a0 (default:eee959fee5f5+, May 13 2016, 11:32:27)
[GCC 6.1.1 20160501] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from test.support import FS_NONASCII
>>> print(FS_NONASCII)
None
>>> And test_ioencoding_nonascii is skipped accordingly on linux for the following printed reason: 'requires OS support of non-ASCII encodings'. On Android, os.fsdecode(os.fsencode('\xe6')) does not raise UnicodeError in the test.support module. And locale.getpreferredencoding() returns 'ascii'. So it seems that this criterion (FS_NONASCII is not None) is not sufficient to decide when this test should be run and not skipped. |
Because of changeset ad6be34ce8c9. |
This patch fixes test_ioencoding_nonascii. |
About the failures in test_c_locale_surrogateescape, it seems that on Android the locale is not set correctly on startup when LC_ALL is set to C: root@generic_x86:/data/local/tmp # LC_ALL=C python
Python 3.6.0a0 (default:eee959fee5f5+, May 14 2016, 10:19:09)
[GCC 4.9 20150123 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale; locale.getlocale()
('en_US', 'UTF-8')
>>> locale.setlocale(locale.LC_ALL, '')
'C'
>>> locale.getlocale()
(None, None)
>>> |
This patch fixes the locale setting on startup when the LC_ALL environment variable is set to C, and as a consequence test_c_locale_surrogateescape does not fail anymore. Note that on Android HAVE_LANGINFO_H is undefined, see issue bpo-22747. |
See also bpo-19058. |
With Serhiy's latest patch named sys_test_ioencoding.patch in bpo-19058, test_sys fails only in test_c_locale_surrogateescape on the android-21-x86 emulator. |
test_c_locale_surrogateescape.patch LGTM. |
For the record, on the Android emulator we have now (not sure where this change has been made):
>>> sys.getfilesystemencoding()
'utf-8'
>>> locale.getpreferredencoding(False)
'ascii' So test_ioencoding_nonascii succeeds now. Anyway the problem with this test is being fixed at bpo-19058. |
New changeset 73bd6bbbb5e2 by Xavier de Gaye in branch '3.6': New changeset f358d849c14e by Xavier de Gaye in branch 'default': |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: