gh-100374: Fixed a bug in socket.getfqdn() (gh-100375)

(cherry picked from commit 12be23cf3c)

Co-authored-by: Dominic Socular <BBH@awsl.rip>
This commit is contained in:
Miss Islington (bot) 2022-12-21 06:06:10 -08:00 committed by GitHub
parent ae8520c709
commit b2076b0071
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -784,11 +784,11 @@ def getfqdn(name=''):
First the hostname returned by gethostbyaddr() is checked, then
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',
was given, it is returned unchanged. If `name` was empty, '0.0.0.0' or '::',
hostname from gethostname() is returned.
"""
name = name.strip()
if not name or name == '0.0.0.0':
if not name or name in ('0.0.0.0', '::'):
name = gethostname()
try:
hostname, aliases, ipaddrs = gethostbyaddr(name)