annotate roundup/anypy/datetime_.py @ 7968:d7e79f8eb943

issue2551350 - Python changes for 3.12 with roundup 2.3.0 mailer.py Fix due to change in smtplib.SMTP.starttls() signature. As of 3.3 it can use an optional ssl context argument for certificates/keys. In 3.12 it dropped legacy support for specifing cert/key files as arguments and requires a context. I modified Andrew's original patch to initialize SSLContext with ssl.PROTOCOL_TLS_CLIENT. If there is a cert file specified, enable check_hostname - verify that the cert supplied by the server matches the hostname we supplied. If there is no cert file call load_default_certs() Also opened issue2551351 to look into more SMTP ssmtp tightening. We also should have an option in Roundup to use TLS/SSL (smtps) without using starttls. Note that this code is untested by the test suite due to the need to setup an SMTP server with STARTTLS support. issue2551351 has some notes on this.
author John Rouillard <rouilj@ieee.org>
date Wed, 15 May 2024 00:08:05 -0400
parents d5d7ecd31864
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7587
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1 # https://issues.roundup-tracker.org/issue2551278
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
2 # datetime.utcnow deprecated
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
3 try:
7767
d5d7ecd31864 chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents: 7589
diff changeset
4 from datetime import UTC, datetime
7587
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
5
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
6 def utcnow():
7589
6894f152d49a fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents: 7587
diff changeset
7 return datetime.now(UTC)
6894f152d49a fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents: 7587
diff changeset
8
7587
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
9 except ImportError:
7589
6894f152d49a fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents: 7587
diff changeset
10 from datetime import datetime
7587
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
11
8f29e4ea05ce fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
12 def utcnow():
7589
6894f152d49a fix: issue2551278 - datetime.datetime.utcnow deprecation.
John Rouillard <rouilj@ieee.org>
parents: 7587
diff changeset
13 return datetime.utcnow()

Roundup Issue Tracker: http://roundup-tracker.org/