FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106432: Added WSL support for adjusting the local hostname by Ineffable22 · Pull Request #106432 · python/cpython · GitHub

/ cpython Public
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 12 additions & 1 deletion Lib/smtplib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import hmac
import copy
import datetime
import platform
import sys
from email.base64mime import body_encode as encode_base64

Expand Down Expand Up @@ -263,7 +264,17 @@ def __init__(self, host='', port=0, local_hostname=None,
# if that can't be calculated, that we should use a domain literal
# instead (essentially an encoded IP address like [A.B.C.D]).
fqdn = socket.getfqdn()
if '.' in fqdn:

# Get information about the platform the program is running on
platform_string = platform.platform().lower()

# Check if the environment is Windows Subsystem for Linux (WSL)
is_wsl = "microsoft" in platform_string and "linux" in platform_string

# If it's WSL, adjust the hostname by removing the last character (the dot)
if is_wsl:
self.local_hostname = fqdn[:-1]
elif '.' in fqdn:
self.local_hostname = fqdn
else:
# We can't find an fqdn hostname, so use a domain literal
Expand Down

Back | FazBrowse Home | New Git URL