gh-112451: Prohibit subclassing of datetime.timezone. (#114190)

This is consistent with C-extension datetime.timezone.
This commit is contained in:
Mariusz Felisiak 2024-01-26 09:33:13 +01:00 committed by GitHub
parent b69548a0f5
commit 456e274578
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -301,6 +301,10 @@ class TestTimeZone(unittest.TestCase):
self.assertIsInstance(timezone.utc, tzinfo)
self.assertIsInstance(self.EST, tzinfo)
def test_cannot_subclass(self):
with self.assertRaises(TypeError):
class MyTimezone(timezone): pass
def test_utcoffset(self):
dummy = self.DT
for h in [0, 1.5, 12]: