diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-09-20 20:39:33 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-09-20 20:39:33 (GMT) |
commit | 3ec153681e4e5553fc6882699beb5af6d45c75e6 (patch) | |
tree | 3c17886d2e7636effa0d7d4b9c7a3b2d1361b61c /Lib | |
parent | 4e12ad19c984dc8dfdb8c326b0ea44c490408579 (diff) | |
download | cpython-3ec153681e4e5553fc6882699beb5af6d45c75e6.zip cpython-3ec153681e4e5553fc6882699beb5af6d45c75e6.tar.gz cpython-3ec153681e4e5553fc6882699beb5af6d45c75e6.tar.bz2 |
Issue #15973: Fixed segmentation fault on timezone comparison to other types.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/datetime.py | 2 | ||||
-rw-r--r-- | Lib/test/datetimetester.py | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 65f95d2..bf23e50 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1821,6 +1821,8 @@ class timezone(tzinfo): return (self._offset, self._name) def __eq__(self, other): + if type(other) != timezone: + return False return self._offset == other._offset def __hash__(self): diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 3fd6799..bb18630 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -235,6 +235,8 @@ class TestTimeZone(unittest.TestCase): self.assertEqual(timezone(-5 * HOUR), timezone(-5 * HOUR, 'EST')) with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO) self.assertIn(timezone(ZERO), {timezone(ZERO)}) + self.assertTrue(timezone(ZERO) != None) + self.assertFalse(timezone(ZERO) == None) def test_aware_datetime(self): # test that timezone instances can be used by datetime |