Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2076b0

Browse files
gh-100374: Fixed a bug in socket.getfqdn() (gh-100375)
(cherry picked from commit12be23c)Co-authored-by: Dominic Socular <BBH@awsl.rip>
1 parentae8520c commitb2076b0

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

‎Lib/socket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,11 @@ def getfqdn(name=''):
784784
785785
First the hostname returned by gethostbyaddr() is checked, then
786786
possibly existing aliases. In case no FQDN is available and `name`
787-
was given, it is returned unchanged. If `name` was empty or'0.0.0.0',
787+
was given, it is returned unchanged. If `name` was empty,'0.0.0.0' or '::',
788788
hostname from gethostname() is returned.
789789
"""
790790
name=name.strip()
791-
ifnotnameorname=='0.0.0.0':
791+
ifnotnameornamein ('0.0.0.0','::'):
792792
name=gethostname()
793793
try:
794794
hostname,aliases,ipaddrs=gethostbyaddr(name)

‎Lib/test/test_socket.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,10 @@ def test_getaddrinfo_ipv6_basic(self):
17601760
)
17611761
self.assertEqual(sockaddr, ('ff02::1de:c0:face:8d',1234,0,0))
17621762

1763+
deftest_getfqdn_filter_localhost(self):
1764+
self.assertEqual(socket.getfqdn(),socket.getfqdn("0.0.0.0"))
1765+
self.assertEqual(socket.getfqdn(),socket.getfqdn("::"))
1766+
17631767
@unittest.skipUnless(socket_helper.IPV6_ENABLED,'IPv6 required for this test.')
17641768
@unittest.skipIf(sys.platform=='win32','does not work on Windows')
17651769
@unittest.skipIf(AIX,'Symbolic scope id does not work')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect result and delay in:func:`socket.getfqdn`. Patch by Dominic Socular.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp