Closed 30ce6405-8009-45b0-95f2-ede633b46a57 closed 2 years ago
In Lib/test/test_socket.py, testGetServBy calls socket.getservbyname(), which needs /etc/services (see "man getservbyname"). If this file is not found, the test fails instead of being skipped.
The attached patch was written against the latest revision of the Mercurial repository. It might be worth applying it for every currently supported version of Python.
Unfortunately, how getservbyname() and other similar network interface functions get their data is platform-dependent. /etc/services is a traditional file location but many modern systems use a database or shared database (e.g. NIS) and even allow the system administrator to dynamically change the source of the data. So, checking for /etc/services would cause the test to be skipped needlessly. I would think that most systems would not be very usable without a working getservbyname(). Under what circumstances is this causing a problem for you?
I don't understand why /etc/services would miss. What is the current behaviour? What is the error message?
I did not know that /etc/services is not always used :/
The main issue is that when you run the test suite in a chroot (to do "pure" builds) or in a network sandbox (for other functions). I get the following errors:
\====================================================================== ERROR: testGetServBy (test.test_socket.GeneralModuleTests) ----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/nix-build-python-3.3.4.drv-0/Python-3.3.4/Lib/test/test_socket.py", line 840, in testGetServBy
raise socket.error
OSError
====================================================================== ERROR: testGetaddrinfo (test.test_socket.GeneralModuleTests) ----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/nix-build-python-3.3.4.drv-0/Python-3.3.4/Lib/test/test_socket.py", line 1126, in testGetaddrinfo
socket.getaddrinfo(HOST, "http")
socket.gaierror: [Errno -8] Servname not supported for ai_socktype
====================================================================== ERROR: test_idna (test.test_socket.GeneralModuleTests) ----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/nix-build-python-3.3.4.drv-0/Python-3.3.4/Lib/test/test_socket.py", line 1186, in test_idna
socket.gethostbyname('\u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435.python.org')
socket.gaierror: [Errno -2] Name or service not known
when you run the test suite in a chroot (to do "pure" builds) or in a network sandbox (for other functions)
Do we support that?
Nope, we don't have to support this edge case.
Note: 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: ```python assignee = None closed_at =
created_at =
labels = []
title = 'Lib/test/test_socket.py: skip testGetServBy if /etc/services is not found'
updated_at =
user = 'https://bugs.python.org/Steap'
```
bugs.python.org fields:
```python
activity =
actor = 'christian.heimes'
assignee = 'none'
closed = True
closed_date =
closer = 'christian.heimes'
components = []
creation =
creator = 'Steap'
dependencies = []
files = ['34304']
hgrepos = []
issue_num = 20868
keywords = ['patch']
message_count = 6.0
messages = ['212910', '212912', '213016', '213635', '406598', '406599']
nosy_count = 5.0
nosy_names = ['vstinner', 'christian.heimes', 'ned.deily', 'Steap', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue20868'
versions = []
```