Skip to content

Commit 87364b0

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Import CPython 3.14.6+ stable branch (2026-08-01)
Summary: Imported python/cpython `3.14.6+` from upstream rev [`3a09a22`](https://www.github.com/python/cpython/commit/3a09a22e7241e2e742898a02589c56e07e6f18e7) (committed 2026-08-01 20:21:13+00:00). # Commit Info - Base: (`3.14.6+`) - [`802a2c8`](https://www.github.com/python/cpython/commit/802a2c8b7a91d700c8bf342a27cd096ac444af41) (commit date: 2026-07-31 17:35:03+00:00) - Imported: (`3.14.6+`) - [`3a09a22`](https://www.github.com/python/cpython/commit/3a09a22e7241e2e742898a02589c56e07e6f18e7) (commit date: 2026-08-01 20:21:13+00:00) # Noteworthy file changes - Low-signal files (1 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GOEY3hZ-f2LZ5ocFAM8_NVG-AIFZbr0LAAAz Reviewed By: itamaro Differential Revision: D114522388 fbshipit-source-id: f49bd4ed210a3624bf67f41be623f62a18a23868
1 parent 0546fc8 commit 87364b0

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,18 @@ def test_unambiguous(self):
316316
self.assertEqual(dt.utcoffset(), offset.utcoffset, dt)
317317
self.assertEqual(dt.dst(), offset.dst, dt)
318318

319+
def test_datetime_subclass_negative_components(self):
320+
class MinusOneDateTime(datetime):
321+
hour = minute = second = -1
322+
323+
zi = self.zone_from_key("UTC")
324+
dt = MinusOneDateTime(2024, 1, 1, tzinfo=zi)
325+
326+
self.assertEqual(dt.utcoffset(), ZERO)
327+
self.assertEqual(dt.dst(), ZERO)
328+
self.assertEqual(dt.tzname(), "UTC")
329+
self.assertEqual(zi.fromutc(dt), datetime(2024, 1, 1, tzinfo=zi))
330+
319331
def test_folds_and_gaps(self):
320332
test_cases = []
321333
for key in self.zones():
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a bug in the C accelerator for :mod:`zoneinfo` where
2+
:class:`datetime.datetime` subclasses returning ``-1`` for ``hour``,
3+
``minute``, or ``second`` could incorrectly raise a :exc:`SystemError`.

Modules/_zoneinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts)
23082308
}
23092309
hour = PyLong_AsLong(num);
23102310
Py_DECREF(num);
2311-
if (hour == -1) {
2311+
if (hour == -1 && PyErr_Occurred()) {
23122312
return -1;
23132313
}
23142314

@@ -2318,7 +2318,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts)
23182318
}
23192319
minute = PyLong_AsLong(num);
23202320
Py_DECREF(num);
2321-
if (minute == -1) {
2321+
if (minute == -1 && PyErr_Occurred()) {
23222322
return -1;
23232323
}
23242324

@@ -2328,7 +2328,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts)
23282328
}
23292329
second = PyLong_AsLong(num);
23302330
Py_DECREF(num);
2331-
if (second == -1) {
2331+
if (second == -1 && PyErr_Occurred()) {
23322332
return -1;
23332333
}
23342334
}

0 commit comments

Comments
 (0)