| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1854,6 +1854,8 @@ def __getinitargs__(self): | |||
| 1854 | 1854 | return (self._offset, self._name) | |
| 1855 | 1855 | ||
| 1856 | 1856 | def __eq__(self, other): | |
| 1857 | + if type(other) != timezone: | ||
| 1858 | + return False | ||
| 1857 | 1859 | return self._offset == other._offset | |
| 1858 | 1860 | ||
| 1859 | 1861 | def __hash__(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,6 +235,8 @@ def test_comparison(self): | |||
| 235 | 235 | self.assertEqual(timezone(-5 * HOUR), timezone(-5 * HOUR, 'EST')) | |
| 236 | 236 | with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO) | |
| 237 | 237 | self.assertIn(timezone(ZERO), {timezone(ZERO)}) | |
| 238 | + self.assertTrue(timezone(ZERO) != None) | ||
| 239 | + self.assertFalse(timezone(ZERO) == None) | ||
| 238 | 240 | ||
| 239 | 241 | def test_aware_datetime(self): | |
| 240 | 242 | # test that timezone instances can be used by datetime | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,9 @@ Library | |||
| 31 | 31 | Extension Modules | |
| 32 | 32 | ----------------- | |
| 33 | 33 | ||
| 34 | + - Issue #15973: Fix a segmentation fault when comparing datetime timezone | ||
| 35 | + objects. | ||
| 36 | + | ||
| 34 | 37 | - Issue #15977: Fix memory leak in Modules/_ssl.c when the function | |
| 35 | 38 | _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. | |
| 36 | 39 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3215,6 +3215,12 @@ timezone_richcompare(PyDateTime_TimeZone *self, | |||
| 3215 | 3215 | { | |
| 3216 | 3216 | if (op != Py_EQ && op != Py_NE) | |
| 3217 | 3217 | Py_RETURN_NOTIMPLEMENTED; | |
| 3218 | + if (Py_TYPE(other) != &PyDateTime_TimeZoneType) { | ||
| 3219 | + if (op == Py_EQ) | ||
| 3220 | + Py_RETURN_FALSE; | ||
| 3221 | + else | ||
| 3222 | + Py_RETURN_TRUE; | ||
| 3223 | + } | ||
| 3218 | 3224 | return delta_richcompare(self->offset, other->offset, op); | |
| 3219 | 3225 | } | |
| 3220 | 3226 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments