Skip to content

Commit

Permalink
bpo-40635: Fix getfqdn() docstring and docs (GH-27971)
Browse files Browse the repository at this point in the history
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit fdcb675)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
  • Loading branch information
miss-islington and akulakov committed Aug 26, 2021
1 parent 970533e commit f1e3fc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Doc/library/socket.rst
Expand Up @@ -795,8 +795,9 @@ The :mod:`socket` module also offers various network-related services:
it is interpreted as the local host. To find the fully qualified name, the
hostname returned by :func:`gethostbyaddr` is checked, followed by aliases for the
host, if available. The first name which includes a period is selected. In
case no fully qualified domain name is available, the hostname as returned by
:func:`gethostname` is returned.
case no fully qualified domain name is available and *name* was provided,
it is returned unchanged. If *name* was empty or equal to ``'0.0.0.0'``,
the hostname from :func:`gethostname` is returned.


.. function:: gethostbyname(hostname)
Expand Down
5 changes: 3 additions & 2 deletions Lib/socket.py
Expand Up @@ -781,8 +781,9 @@ def getfqdn(name=''):
An empty argument is interpreted as meaning the local host.
First the hostname returned by gethostbyaddr() is checked, then
possibly existing aliases. In case no FQDN is available, hostname
from gethostname() is returned.
possibly existing aliases. In case no FQDN is available and `name`
was given, it is returned unchanged. If `name` was empty or '0.0.0.0',
hostname from gethostname() is returned.
"""
name = name.strip()
if not name or name == '0.0.0.0':
Expand Down

0 comments on commit f1e3fc4

Please sign in to comment.