classification
Title: [asyncio] bind() on a unix socket raises PermissionError on Android for a non-root user
Type: behavior Stage: resolved
Components: asyncio, Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner, xdegaye, yselivanov
Priority: normal Keywords: patch

Created on 2016-11-13 20:39 by xdegaye, last changed 2017-11-24 17:56 by xdegaye. This issue is now closed.

Files
File name Uploaded Description Edit
test_asyncio.log xdegaye, 2016-11-13 20:39
test_asyncio_bind.patch xdegaye, 2016-11-17 12:45 review
Pull Requests
URL Status Linked Edit
PR 4503 merged xdegaye, 2017-11-22 17:00
PR 4547 merged xdegaye, 2017-11-24 17:38
Messages (5)
msg280714 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-11-13 20:39
Tests in test_asyncio fail on Android when bind() on a unix socket raises PermissionError for a non-root user. See the attached test_asyncio.log. See also issue 28683 and its patch(es).
msg280769 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-11-14 13:03
I suggest to write a decorator in Lib/asyncio/test_utils.py to skip AF_UNIX tests on Android if os.getuid() != 0.

Another approach is to catch the PermissionError and re-raises an unittest.SkipTest. Begin by modifying unix_socket_path() context manager in Lib/asyncio/test_utils.py.

I prefer the approach catching PermissionError: it allows to run unit tests on a flavor of Android which doesn't raise PermissionError, and it handles PermissionError on other platforms.
msg281038 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-11-17 12:45
With this patch, test_asyncio runs successfully with no ResourceWarning when run on the android-24 emulator.
msg306904 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2017-11-24 16:35
New changeset 0f86cd38f4a38f25a4aed3759a654a4b7fa49031 by xdegaye in branch 'master':
bpo-28684: asyncio tests handle PermissionError raised on binding unix sockets (GH-4503)
https://github.com/python/cpython/commit/0f86cd38f4a38f25a4aed3759a654a4b7fa49031
msg306911 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2017-11-24 17:56
New changeset 5742f674f7561dc9a1fc66d650e18e31b941183b by xdegaye in branch 'master':
bpo-28684: Remove useless import added by the previous commit (GH-4547)
https://github.com/python/cpython/commit/5742f674f7561dc9a1fc66d650e18e31b941183b
History
Date User Action Args
2017-11-24 17:56:24xdegayesetmessages: + msg306911
2017-11-24 17:38:09xdegayesetpull_requests: + pull_request4477
2017-11-24 16:36:58xdegayesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-11-24 16:35:58xdegayesetmessages: + msg306904
2017-11-24 16:27:06xdegayesetversions: - Python 3.6
2017-11-22 17:00:38xdegayesetpull_requests: + pull_request4441
2016-11-21 15:40:04xdegayelinkissue26865 dependencies
2016-11-17 21:25:12giampaolo.rodolasetnosy: - giampaolo.rodola
2016-11-17 21:24:27gvanrossumsetnosy: - gvanrossum
2016-11-17 12:45:48xdegayesetfiles: + test_asyncio_bind.patch
keywords: + patch
messages: + msg281038

stage: needs patch -> patch review
2016-11-14 13:03:52vstinnersetmessages: + msg280769
2016-11-13 20:39:34xdegayecreate