You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 getaddrinfofor 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
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
>>>
xdegaye commented on May 10, 2016
xdegayemannequin
MannequinAuthor
More actions
testGetaddrinfo does not fail anymore on an emulator running an android-23-x86, i.e. Android 6.0 or API 23.
xdegaye commented on May 25, 2016
xdegayemannequin
MannequinAuthor
More actions
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.
xdegaye commented on May 25, 2016
xdegayemannequin
MannequinAuthor
More actions
This patch fixes the testGetServBy test for API 21 and 23 (fixing the cases a) and e) of my previous msg).
xdegaye commented on May 25, 2016
xdegayemannequin
MannequinAuthor
More actions
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.
xdegaye commented on Oct 30, 2016
xdegayemannequin
MannequinAuthor
More actions
This patch simply skips the statements that fail on Android.
Activity
xdegaye commentedon May 3, 2016
test_socket fails on an android emulator running an x86 system image at API level 21.
======================================================================
ERROR: testGetServBy (test.test_socket.GeneralModuleTests)
----------------------------------------------------------------------
======================================================================
ERROR: testGetaddrinfo (test.test_socket.GeneralModuleTests)
----------------------------------------------------------------------
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
xdegaye commentedon May 7, 2016
On android getservbyname(const char *NAME, const char *PROTO) returns NULL when PROTO is NULL:
On android socket.getaddrinfo() raises an exception when port is not a number:
xdegaye commentedon May 10, 2016
testGetaddrinfo does not fail anymore on an emulator running an android-23-x86, i.e. Android 6.0 or API 23.
xdegaye commentedon May 25, 2016
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.
xdegaye commentedon May 25, 2016
This patch fixes the testGetServBy test for API 21 and 23 (fixing the cases a) and e) of my previous msg).
xdegaye commentedon May 25, 2016
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.
xdegaye commentedon Oct 30, 2016
This patch simply skips the statements that fail on Android.
xdegaye commentedon Oct 31, 2016
Entered https://code.google.com/p/android/issues/detail?id=226677 on the AOSP issue tracker.
xdegaye commentedon Nov 18, 2016
New patch using support.less_than_android_api(level).
xdegaye commentedon Dec 12, 2016
New patch using sys.getandroidapilevel().
getandroidapilevel() is only available in 3.7, so only 3.7 is being fixed.
python-dev commentedon Dec 13, 2016
New changeset 95140ff32239 by Xavier de Gaye in branch 'default':
Issue bpo-26936: Fix the test_socket failures on Android - getservbyname(),
https://hg.python.org/cpython/rev/95140ff32239