Issue26936
Created on 2016-05-03 15:10 by xdegaye, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| null-proto.patch | xdegaye, 2016-05-25 14:36 | review | ||
| test-getaddrinfo.patch | xdegaye, 2016-05-25 14:40 | review | ||
| test_socket.patch | xdegaye, 2016-10-30 16:39 | review | ||
| test_socket_2.patch | xdegaye, 2016-11-18 15:48 | review | ||
| test_socket_3.patch | xdegaye, 2016-12-12 15:16 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017-03-31 16:36 | |
| Messages (11) | |||
|---|---|---|---|
| msg264737 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-03 15:10 | |
test_socket fails on an android emulator running an x86 system image at API level 21. ====================================================================== ERROR: testGetServBy (test.test_socket.GeneralModuleTests) ---------------------------------------------------------------------- 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 ====================================================================== ERROR: testGetaddrinfo (test.test_socket.GeneralModuleTests) ---------------------------------------------------------------------- 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) test test_socket failed 1 test failed: test_socket Total duration: 0:00:27 |
|||
| msg265078 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-07 16:47 | |
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 >>> |
|||
| msg265250 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-10 14:52 | |
testGetaddrinfo does not fail anymore on an emulator running an android-23-x86, i.e. Android 6.0 or API 23. |
|||
| msg266362 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-25 14:33 | |
Problems with the socket module on Android:
API 21:
a) Both getservbyname() and getservbyport() fail when the optional 'protocolname' parameter is not set to 'tcp' or 'udp'.
b) getservbyname() fails when 'servicename' is set to 'http'.
getaddrinfo() fails either when:
c) 'port' is 'http'.
d) Or the optional 'type' is not set to socket.SOCK_STREAM or socket.SOCK_DGRAM and 'port' is a string.
API 23:
e) getservbyport() fails when the optional 'protocolname' parameter is not set to 'tcp' or 'udp'.
IMHO case b) and c) are difficult to fix.
For case d), one could use the Python implementation of getaddrinfo, but Android does not have the deprecated getipnodebyaddr(), so it is necessary to disable ipv6 in this case. Not sure if this is worth it.
|
|||
| msg266363 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-25 14:36 | |
This patch fixes the testGetServBy test for API 21 and 23 (fixing the cases a) and e) of my previous msg). |
|||
| msg266365 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-05-25 14:40 | |
This patch fixes the testGetaddrinfo test for API 21 (the test runs fine on API 23):
The failing statement 'socket.getaddrinfo(HOST, "http")' in testGetaddrinfo does not test explicitly for "http" and for the absence of the optional 'type' parameter.
When is_android is True, the 'socket.getaddrinfo('127.0.0.1', "echo", type=socket.SOCK_DGRAM)' statement is run instead and the test is ok.
|
|||
| msg279730 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-10-30 16:39 | |
This patch simply skips the statements that fail on Android. |
|||
| msg279773 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-10-31 09:00 | |
Entered https://code.google.com/p/android/issues/detail?id=226677 on the AOSP issue tracker. |
|||
| msg281130 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-11-18 15:48 | |
New patch using support.less_than_android_api(level). |
|||
| msg283009 - (view) | Author: Xavier de Gaye (xdegaye) * | Date: 2016-12-12 15:16 | |
New patch using sys.getandroidapilevel(). getandroidapilevel() is only available in 3.7, so only 3.7 is being fixed. |
|||
| msg283084 - (view) | Author: Roundup Robot (python-dev) | Date: 2016-12-13 08:22 | |
New changeset 95140ff32239 by Xavier de Gaye in branch 'default': Issue #26936: Fix the test_socket failures on Android - getservbyname(), https://hg.python.org/cpython/rev/95140ff32239 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:30 | admin | set | github: 71123 |
| 2017-03-31 16:36:29 | dstufft | set | pull_requests: + pull_request1025 |
| 2016-12-13 09:12:57 | xdegaye | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2016-12-13 08:22:44 | python-dev | set | nosy:
+ python-dev messages: + msg283084 |
| 2016-12-12 15:16:10 | xdegaye | set | files:
+ test_socket_3.patch stage: commit review -> patch review |
| 2016-11-18 15:48:44 | xdegaye | set | files:
+ test_socket_2.patch messages:
+ msg281130 |
| 2016-10-31 09:00:38 | xdegaye | set | messages: + msg279773 |
| 2016-10-30 16:39:47 | xdegaye | set | files:
+ test_socket.patch versions: + Python 3.7 messages: + msg279730 assignee: xdegaye |
| 2016-05-25 14:40:43 | xdegaye | set | files:
+ test-getaddrinfo.patch dependencies:
+ add the 'is_android' attribute to test.support |
| 2016-05-25 14:36:50 | xdegaye | set | files:
+ null-proto.patch keywords: + patch messages: + msg266363 |
| 2016-05-25 14:33:33 | xdegaye | set | messages: + msg266362 |
| 2016-05-21 07:06:39 | xdegaye | link | issue26865 dependencies |
| 2016-05-10 14:52:20 | xdegaye | set | messages: + msg265250 |
| 2016-05-07 16:47:13 | xdegaye | set | messages: + msg265078 |
| 2016-05-03 15:10:46 | xdegaye | create | |