cpython/Modules
Miss Islington (bot) 36d42e701f
Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582)
The `utc_to_seconds` call can fail, here's a minimal reproducer on
Linux:

TZ=UTC python -c "from datetime import *; datetime.fromtimestamp(253402300799 + 1)"

The old behavior still raised an error in a similar way, but only
because subsequent calculations happened to fail as well. Better to fail
fast.

This also refactors the tests to split out the `fromtimestamp` and
`utcfromtimestamp` tests, and to get us closer to the actual desired
limits of the functions. As part of this, we also changed the way we
detect platforms where the same limits don't necessarily apply (e.g.
Windows).

As part of refactoring the tests to hit this condition explicitly (even
though the user-facing behvior doesn't change in any way we plan to
guarantee), I noticed that there was a difference in the places that
`datetime.utcfromtimestamp` fails in the C and pure Python versions, which
was fixed by skipping the "probe for fold" logic for UTC specifically —
since UTC doesn't have any folds or gaps, we were never going to find a
fold value anyway. This should prevent some failures in the pure python
`utcfromtimestamp` method on timestamps close to 0001-01-01.

There are two separate news entries for this because one is a
potentially user-facing change, the other is an internal code
correctness change that, if anything, changes some error messages. The
two happen to be coupled because of the test refactoring, but they are
probably best thought of as independent changes.

Fixes GH-91581
(cherry picked from commit 83c0247d47)

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2022-05-14 08:01:53 -07:00
..
_blake2 bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792) 2021-05-02 09:47:45 +02:00
_ctypes [3.10] gh-91118: Fix docstrings that do not honor --without-doc-strings (GH-31769) (#91662) 2022-04-19 13:01:09 -07:00
_decimal bpo-45332: Fix broken Decimal test and benchmark (GH-28680) 2021-10-01 07:16:37 -07:00
_io bpo-25415: Remove confusing sentence from IOBase docstrings (PR-31631) 2022-03-04 10:33:57 -08:00
_multiprocessing bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 2020-12-01 10:37:39 +01:00
_sha3 bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927) 2021-05-05 15:05:22 -07:00
_sqlite [3.10] gh-80254: Disallow recursive usage of cursors in sqlite3 converters (#92274) 2022-05-05 12:46:21 -07:00
_ssl bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792) 2021-05-02 09:47:45 +02:00
_xxtestfuzz Fix typo in fuzzer.c (GH-25013) 2021-03-25 00:47:21 +09:00
cjkcodecs bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
clinic [3.10] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92079) 2022-05-03 11:53:46 +03:00
expat bpo-46932: Update bundled libexpat to 2.4.7 (GH-31736) 2022-03-07 14:17:29 -08:00
_abc.c bpo-43977: Properly update the tp_flags of existing subclasses when their parents are registered (GH-26864) 2021-06-25 08:46:23 -07:00
_asynciomodule.c [3.10] bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777) (#30784) 2022-01-22 14:28:51 +02:00
_bisectmodule.c [3.10] Remove trailing spaces (GH-28709) 2021-10-03 20:03:49 +03:00
_bz2module.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_codecsmodule.c [3.10] bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944) (GH-28952) 2021-10-14 21:23:39 +03:00
_collectionsmodule.c bpo-41621: Document defaultdict's default_factory parameter (GH-21945) 2021-06-23 10:58:20 -04:00
_contextvarsmodule.c bpo-1635741: _contextvars uses PyModule_AddType() (GH-23147) 2020-11-04 16:33:55 +01:00
_cryptmodule.c closes bpo-44751: Move crypt.h include from public header to _cryptmodule (GH-27394) (GH-28636) 2021-09-30 01:02:11 +02:00
_csv.c [3.10] bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832) (GH-28834) 2021-10-10 01:13:21 +09:00
_curses_panel.c bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721) 2021-04-30 12:46:15 +02:00
_cursesmodule.c bpo-46000: Improve NetBSD curses compatibility (GH-29947) 2021-12-10 02:29:23 -08:00
_datetimemodule.c Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582) 2022-05-14 08:01:53 -07:00
_dbmmodule.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_elementtree.c bpo-45948: Remove constructor discrepancy in C version of ElementTree.XMLParser (GH-31152) 2022-02-12 00:50:11 -08:00
_functoolsmodule.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_gdbmmodule.c [3.10] bpo-45060: Get rid of few uses of the equality operators with None (GH-28087). (GH-28092) 2021-09-03 21:13:00 -04:00
_hashopenssl.c [3.10] bpo-47101: list only activated algorithms in hashlib.algorithms_available (GH-32076) (GH-32085) 2022-03-23 22:15:25 +01:00
_heapqmodule.c bpo-41078: Add pycore_list.h internal header file (GH-21057) 2020-06-22 17:39:32 +02:00
_json.c [3.10] Remove trailing spaces (GH-28709) 2021-10-03 20:03:49 +03:00
_localemodule.c bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586) 2020-12-01 09:56:42 +01:00
_lsprof.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_lzmamodule.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_math.c [3.10] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28511) 2021-09-22 01:33:59 +02:00
_math.h Issue #28256: Cleanup _math.c 2016-10-18 16:29:27 +02:00
_opcode.c bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050) 2020-09-07 10:48:44 +02:00
_operator.c bpo-44558: Match countOf is/== treatment to c (GH-27007) 2021-07-07 06:50:41 -07:00
_pickle.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
_posixsubprocess.c [3.10] gh-91401: Conservative backport of subprocess._USE_VFORK (#91932) 2022-05-01 16:09:50 -07:00
_queuemodule.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
_randommodule.c Eliminate duplicated assignment in _randommodule.c (GH-25904) (GH-25909) 2021-05-04 21:39:09 -07:00
_scproxy.c bpo-1635741: port scproxy to multi-phase init (GH-22164) 2020-09-09 12:28:48 +09:00
_sre.c bpo-23691: Protect the re.finditer() iterator from re-entering (GH-32012) 2022-03-21 04:30:58 -07:00
_ssl.c bpo-46232: Fix parsing of certs with bit string in DN (GH-30351) 2022-02-21 01:37:26 -08:00
_ssl.h bpo-18233: Add internal methods to access peer chain (GH-25467) 2021-04-26 15:01:40 +02:00
_ssl_data.h closes bpo-40266, closes bpo-39953: Use numeric lib code if compiling against old OpenSSL. (GH-19506) 2020-04-13 22:11:40 -05:00
_ssl_data_111.h bpo-43788: Generate version specific _ssl_data.h (GH-25300) 2021-04-09 08:02:00 -07:00
_ssl_data_300.h bpo-43788: Generate version specific _ssl_data.h (GH-25300) 2021-04-09 08:02:00 -07:00
_stat.c bpo-40677: Define IO_REPARSE_TAG_APPEXECLINK explicitly (GH-20206) 2020-05-19 13:22:16 +01:00
_statisticsmodule.c bpo-40268: Remove unused structmember.h includes (GH-19530) 2020-04-15 02:35:41 +02:00
_struct.c bpo-40137: Add pycore_moduleobject.h internal header (GH-25507) 2021-04-22 00:52:52 +02:00
_testbuffer.c bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 2020-12-01 10:37:39 +01:00
_testcapimodule.c [3.10] gh-91118: Fix docstrings that do not honor --without-doc-strings (GH-31769) (#91662) 2022-04-19 13:01:09 -07:00
_testimportmultiple.c
_testinternalcapi.c bpo-38530: Refactor and improve AttributeError suggestions (GH-25776) 2021-05-03 16:47:27 +01:00
_testmultiphase.c [3.10] bpo-46433: _PyType_GetModuleByDef: handle static types in MRO (GH-30696) (GH-31262) 2022-02-11 12:25:25 +01:00
_threadmodule.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
_tkinter.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
_tracemalloc.c bpo-46280: Fix tracemalloc_copy_domain() (GH-30591) 2022-01-13 20:32:40 -08:00
_uuidmodule.c bpo-40501: Replace ctypes code in uuid with native module (GH-19948) 2020-05-12 23:32:32 +01:00
_weakref.c bpo-40170: PyObject_GET_WEAKREFS_LISTPTR() becomes a function (GH-19377) 2020-04-06 14:07:02 +02:00
_winapi.c Update URLs in comments and metadata to use HTTPS (GH-27458) (GH-27478) 2021-07-30 16:25:28 +02:00
_xxsubinterpretersmodule.c bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721) 2021-04-30 12:46:15 +02:00
_zoneinfo.c bpo-46383: Fix signature of zoneinfo module_free function (GH-30607) (GH-30610) 2022-01-17 14:47:51 +01:00
addrinfo.h replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
arraymodule.c [3.10] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28511) 2021-09-22 01:33:59 +02:00
atexitmodule.c bpo-46025: Fix a crash in the atexit module for auto-unregistering functions (GH-30002) (GH-30005) 2021-12-09 15:16:09 +00:00
audioop.c [3.10] bpo-46513: Remove AC_C_CHAR_UNSIGNED / __CHAR_UNSIGNED__ (GH-30851) (GH-30914) 2022-01-26 12:20:31 +01:00
binascii.c [3.10] bpo-38256: Fix binascii.crc32 large input. (GH-32000) (GH-32013) 2022-03-20 14:46:52 -07:00
cmathmodule.c bpo-1635741: Port cmath to multi-phase init (PEP 489) (GH-22165) 2020-09-10 16:09:04 +02:00
config.c.in rename _imp initialization function to follow conventions (#5432) 2018-01-29 11:33:57 -08:00
errnomodule.c bpo-1635741: Port errno module to multiphase initialization (GH-19923) 2020-05-07 10:17:16 +09:00
faulthandler.c [3.10] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961). (GH-31974) 2022-03-18 13:33:11 +00:00
fcntlmodule.c bpo-41586: Add pipesize parameter to subprocess & F_GETPIPE_SZ and F_SETPIPE_SZ to fcntl. (GH-21921) 2020-10-19 16:30:02 -07:00
gc_weakref.txt [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
gcmodule.c gh-92036: Fix gc_fini_untrack() (GH-92037) 2022-05-04 03:23:29 -07:00
getaddrinfo.c bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748) 2017-12-12 13:55:04 +02:00
getbuildinfo.c bpo-45532: Replace 'default' with 'main' as default in sys.version (GH-29100) 2021-10-20 10:41:35 -07:00
getnameinfo.c
getpath.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
grpmodule.c bpo-1635741: Port grp and pwd to multiphase initialization (GH-23360) 2020-11-18 23:47:32 -08:00
hashlib.h hashlib: Fix old message about unicode objects. (GH-28653) 2021-10-01 05:58:37 -07:00
itertoolsmodule.c [3.10] bpo-46728: fix docstring of combinations_with_replacement for consistency (GH-31293) (GH-31350) 2022-02-15 19:24:04 +09:00
ld_so_aix.in Issue #10656: Fix out-of-tree building on AIX 2016-11-20 07:56:37 +00:00
main.c Typo in comment (GH-24199) 2021-01-25 14:51:48 -08:00
makesetup bpo-45571: use PY_CFLAGS_NODIST for shared Modules/Setup (GH-29161) 2021-10-22 11:22:01 -07:00
makexp_aix bpo-42087: Remove support for AIX 5.3 and below (GH-22830) 2020-11-16 16:16:10 +01:00
mathmodule.c bpo-46018: Ensure that math.expm1 does not raise on underflow (GH-29997) 2021-12-09 11:37:06 -08:00
md5module.c [3.10] bpo-42972: Fully support GC for hashlib heap types (GH-26374) (GH-26398) 2021-05-27 01:10:39 -07:00
mmapmodule.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
nismodule.c bpo-40950: Port nis module to multiphase initialization (GH-20811) 2020-06-12 11:26:00 +09:00
ossaudiodev.c gh-91734: Fix ossaudio support on Solaris (GH-91735) 2022-04-20 04:06:29 -07:00
overlapped.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
posixmodule.c bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) 2022-05-10 23:52:39 +01:00
posixmodule.h [3.10] bpo-41498: Fix build on platforms without sigset_t (GH-29770) (GH-29773) 2021-11-25 03:53:07 -08:00
pwdmodule.c bpo-1635741: Port grp and pwd to multiphase initialization (GH-23360) 2020-11-18 23:47:32 -08:00
pyexpat.c bpo-45329: Fix freed memory access in pyexpat.c (GH-28649) 2021-10-02 06:21:55 -07:00
readline.c bpo-42819, readline: Disable bracketed paste (GH-24108) 2021-02-16 00:28:24 +01:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
resource.c bpo-42960: Add resource.RLIMIT_KQUEUES constant from FreeBSD (GH-24251) 2021-02-18 16:26:20 +01:00
rotatingtree.c
rotatingtree.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
selectmodule.c [3.10] bpo-41857: mention timeout argument units in select.poll() and select.depoll() doc-strings (GH-22406) 2022-01-21 11:02:25 +02:00
Setup bpo-40137: Add pycore_moduleobject.h internal header (GH-25507) 2021-04-22 00:52:52 +02:00
sha1module.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
sha256module.c [3.10] bpo-42972: Fully support GC for hashlib heap types (GH-26374) (GH-26398) 2021-05-27 01:10:39 -07:00
sha512module.c [3.10] bpo-42972: Fully support GC for hashlib heap types (GH-26374) (GH-26398) 2021-05-27 01:10:39 -07:00
signalmodule.c bpo-23325: Fix SIG_IGN and SIG_DFL int comparison in signal module (GH-31759) 2022-03-08 10:53:24 -08:00
socketmodule.c [3.10] bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (GH-32140) 2022-03-28 11:26:49 -07:00
socketmodule.h bpo-41798: Allocate _socket module C API on the heap (GH-24126) 2021-01-06 20:43:06 +01:00
spwdmodule.c bpo-1635741: Port spwd to multiphase initialization (GH-23390) 2020-11-19 10:54:03 +01:00
sre.h bpo-23691: Protect the re.finditer() iterator from re-entering (GH-32012) 2022-03-21 04:30:58 -07:00
sre_constants.h bpo-31690: Allow the inline flags "a", "L", and "u" to be used as group flags for RE. (#3885) 2017-10-24 23:31:42 +03:00
sre_lib.h bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 2020-12-01 10:37:39 +01:00
symtablemodule.c bpo-42725: Render annotations effectless on symbol table with PEP 563 (GH-25583) 2021-05-03 10:43:00 +03:00
syslogmodule.c [3.10] Fix typos in the Modules directory (GH-28761) (GH-28781) 2021-10-07 01:55:18 -07:00
termios.c [3.10] Remove trailing spaces (GH-28709) 2021-10-03 20:03:49 +03:00
testcapi_long.h
timemodule.c bpo-37205: time.time() cannot fail with fatal error (GH-23314) 2020-11-16 16:08:05 +01:00
tkappinit.c Issue #4350: Removed a number of out-of-dated and non-working for a long time 2014-07-23 22:33:50 +03:00
tkinter.h Issue #16840. Turn off bignum support in tkinter with with Tcl earlier than 8.5.8 2015-04-22 10:59:32 +03:00
unicodedata.c bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766) 2021-06-17 11:19:44 +01:00
unicodedata_db.h closes bpo-39926: Update Unicode to 13.0.0. (GH-18910) 2020-03-10 20:41:34 -07:00
unicodename_db.h closes bpo-39926: Update Unicode to 13.0.0. (GH-18910) 2020-03-10 20:41:34 -07:00
winreparse.h bpo-31512: Add non-elevated symlink support for Windows (GH-3652) 2019-04-09 11:19:46 -07:00
xxlimited.c bpo-42972: Fully implement GC protocol for xxlimited (GH-26451) (GH-26460) 2021-05-31 12:23:13 +01:00
xxlimited_35.c bpo-42972: Fully implement GC protocol for xxlimited (GH-26451) (GH-26460) 2021-05-31 12:23:13 +01:00
xxmodule.c bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587) 2020-12-01 10:37:39 +01:00
xxsubtype.c bpo-40268: Remove unused structmember.h includes (GH-19530) 2020-04-15 02:35:41 +02:00
zlibmodule.c [3.10] bpo-41735: Fix thread lock in zlib.Decompress.flush() may go wrong (GH-29587) (GH-29811) 2021-11-26 16:42:00 -08:00

Source files for standard library extension modules,
and former extension modules that are now builtin modules.