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_socket fails #71123
Comments
test_socket fails on an android emulator running an x86 system image at API level 21. ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_socket.py", line 913, in testGetServBy
port2 = socket.getservbyname(service)
OSError: service/proto not found ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_socket.py", line 1240, in testGetaddrinfo
socket.getaddrinfo(HOST, "http")
File "/sdcard/org.bitbucket.pyona/lib/python3.6/socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 9] servname not supported for ai_socktype Ran 530 tests in 26.702s FAILED (errors=2, skipped=75) |
On android getservbyname(const char *NAME, const char *PROTO) returns NULL when PROTO is NULL: root@generic_x86:/data/local/tmp # python
Python 3.6.0a0 (default:811ccdee6f87+, May 7 2016, 17:56:37)
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getservbyname('daytime', 'tcp')
13
>>> socket.getservbyname('daytime', 'udp')
13
>>> socket.getservbyname('daytime')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: service/proto not found
>>> On android socket.getaddrinfo() raises an exception when port is not a number: >>> socket.getaddrinfo('127.0.0.1', 80)
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 80))]
>>> socket.getaddrinfo('127.0.0.1', 'http')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/sdcard/org.bitbucket.pyona/lib/python3.6/socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 9] servname not supported for ai_socktype
>>> |
testGetaddrinfo does not fail anymore on an emulator running an android-23-x86, i.e. Android 6.0 or API 23. |
Problems with the socket module on Android: API 23: IMHO case b) and c) are difficult to fix. |
This patch fixes the testGetServBy test for API 21 and 23 (fixing the cases a) and e) of my previous msg). |
This patch fixes the testGetaddrinfo test for API 21 (the test runs fine on API 23): |
This patch simply skips the statements that fail on Android. |
Entered https://code.google.com/p/android/issues/detail?id=226677 on the AOSP issue tracker. |
New patch using support.less_than_android_api(level). |
New patch using sys.getandroidapilevel(). |
New changeset 95140ff32239 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: