Skip to content

Commit 12c93ee

Browse files
committed
5.12.12
- Do not attempt to include an SMTP error code when none is provided (Close #189)
1 parent e90178f commit 12c93ee

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 5.12.12
4+
5+
- Do not attempt to include an SMTP error code when none is provided (Close #189)
6+
37
## 5.12.11
48

59
- Remove unneeded `finally` blocks in `smtp.py` that were causing warnings in Python 3.14 (Close #178)

checkdmarc/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
See the License for the specific language governing permissions and
2020
limitations under the License."""
2121

22-
__version__ = "5.12.11"
22+
__version__ = "5.12.12"
2323

2424
OS = platform.system()
2525
OS_RELEASE = platform.release()

checkdmarc/smtp.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ def test_tls(
181181
raise SMTPError(error)
182182
except smtplib.SMTPException as e:
183183
error = e.__str__()
184-
error_code = error.lstrip("(").split(",")[0]
185-
error = f"SMTP error code {error_code}"
184+
try:
185+
error_code = error.lstrip("(").split(",")[0]
186+
error = f"SMTP error code {error_code}"
187+
except ValueError:
188+
pass
186189
if cache:
187190
cache[hostname] = dict(tls=False, error=error)
188191
raise SMTPError(error)
@@ -300,9 +303,12 @@ def test_starttls(
300303
cache[hostname] = dict(starttls=False, error=error)
301304
raise SMTPError(error)
302305
except smtplib.SMTPException as e:
303-
message = e.__str__()
304-
error_code = int(message.lstrip("(").split(",")[0])
305-
error = f"SMTP error code {error_code}"
306+
error = e.__str__()
307+
try:
308+
error_code = error.lstrip("(").split(",")[0]
309+
error = f"SMTP error code {error_code}"
310+
except ValueError:
311+
pass
306312
if cache:
307313
cache[hostname] = dict(starttls=False, error=error)
308314
raise SMTPError(error)

0 commit comments

Comments
 (0)