cpython/Modules
Paul Ganssle 83c0247d47
Check result of utc_to_seconds and skip fold probe in pure Python (#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
2022-05-12 17:00:50 -04:00
..
_blake2 bpo-47095: Use libb2 to provide blake2 implementation (GH-32059) 2022-03-26 20:52:24 +01:00
_ctypes gh-92356: Fix regression in ctypes function call overhead (#92357) 2022-05-05 20:59:45 -07:00
_decimal gh-92584: test_decimal uses shutil.which() (#92640) 2022-05-11 01:42:09 +02:00
_io gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
_multiprocessing gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) 2022-05-03 20:25:41 +02:00
_sha3 bpo-47098: Replace Keccak Code Package with tiny_sha3 (GH-32060) 2022-03-26 21:36:08 +01:00
_sqlite gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572) 2022-05-04 07:16:01 -06:00
_sre gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) 2022-05-03 20:25:41 +02:00
_ssl gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) 2022-05-03 20:25:41 +02:00
_xxtestfuzz
cjkcodecs gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210) 2022-05-03 20:25:41 +02:00
clinic gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
expat bpo-46932: Update bundled libexpat to 2.4.7 (GH-31736) 2022-03-07 21:46:18 +00:00
_abc.c bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928) 2022-02-08 13:39:07 -07:00
_asynciomodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_bisectmodule.c gh-90699: Use module state to access insert str object. (GH-91693) 2022-04-19 22:12:46 +09:00
_bz2module.c
_codecsmodule.c
_collectionsmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_contextvarsmodule.c
_cryptmodule.c
_csv.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_curses_panel.c
_cursesmodule.c bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928) 2022-02-08 13:39:07 -07:00
_datetimemodule.c Check result of utc_to_seconds and skip fold probe in pure Python (#91582) 2022-05-12 17:00:50 -04:00
_dbmmodule.c gh-89452: Prefer gdbm-compat over ndbm (#92208) 2022-05-03 18:27:38 +02:00
_elementtree.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_functoolsmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_gdbmmodule.c bpo-46541: Remove usage of _Py_IDENTIFIER from dbms modules (GH-31358) 2022-02-16 18:57:28 +09:00
_hashopenssl.c bpo-47101: list only activated algorithms in hashlib.algorithms_available (GH-32076) 2022-03-23 13:30:05 -07:00
_heapqmodule.c
_json.c Use static inline function Py_EnterRecursiveCall() (#91988) 2022-05-04 13:30:23 +02:00
_localemodule.c bpo-47000: Add locale.getencoding() (GH-32068) 2022-04-09 09:54:54 +09:00
_lsprof.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_lzmamodule.c bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module (GH-31683) 2022-03-05 01:38:56 +09:00
_math.h
_opcode.c bpo-46072: Add --with-pystats configure option to simplify gathering of VM stats (GH-30116) 2021-12-15 15:32:32 +00:00
_operator.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_pickle.c Use static inline function Py_EnterRecursiveCall() (#91988) 2022-05-04 13:30:23 +02:00
_posixsubprocess.c gh-82616: Add process_group support to subprocess.Popen (#23930) 2022-05-05 16:22:32 -07:00
_queuemodule.c bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081) 2022-02-11 17:22:11 +01:00
_randommodule.c bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081) 2022-02-11 17:22:11 +01:00
_scproxy.c
_ssl.c bpo-46541: remove usage of _Py_IDENTIFIER from _ssl module (GH-31599) 2022-03-02 00:38:21 +09:00
_ssl.h bpo-46541: remove usage of _Py_IDENTIFIER from _ssl module (GH-31599) 2022-03-02 00:38:21 +09:00
_ssl_data.h
_ssl_data_111.h
_ssl_data_300.h
_stat.c
_statisticsmodule.c
_struct.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_testbuffer.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_testcapi_feature_macros.inc gh-91324: List feature macros in the stable ABI manifest, improve tests (GH-32415) 2022-04-28 16:30:28 +02:00
_testcapimodule.c gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
_testimportmultiple.c
_testinternalcapi.c GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
_testmultiphase.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_threadmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_tkinter.c bpo-46996: Remove support of Tcl/Tk < 8.5.12 (GH-31839) 2022-03-17 13:05:52 +02:00
_tracemalloc.c bpo-47177: Replace f_lasti with prev_instr (GH-32208) 2022-04-07 12:31:01 -07:00
_typingmodule.c
_uuidmodule.c
_weakref.c bpo-46937: convert remaining functions to AC in _weakref (GH-31705) 2022-03-07 18:57:45 +09:00
_winapi.c
_xxsubinterpretersmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
_zoneinfo.c bpo-46383: Fix signature of zoneinfo module_free function (GH-30607) 2022-01-15 09:52:19 +01:00
addrinfo.h
arraymodule.c bpo-47070: Add _PyBytes_Repeat() (GH-31999) 2022-03-28 04:43:45 -04:00
atexitmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
audioop.c Deprecate audioop (GH-32392) 2022-04-07 12:27:35 -07:00
binascii.c bpo-38256: Fix binascii.crc32() when inputs are 4+GiB (GH-32000) 2022-03-20 12:28:15 -07:00
cmathmodule.c bpo-46656: Remove Py_NO_NAN macro (GH-31160) 2022-02-25 01:32:57 +01:00
config.c.in
errnomodule.c
faulthandler.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
fcntlmodule.c
gc_weakref.txt
gcmodule.c gh-92036: Fix gc_fini_untrack() (#92037) 2022-05-04 11:59:01 +02:00
getaddrinfo.c
getbuildinfo.c
getnameinfo.c
getpath.c bpo-46890: Fix setting of sys._base_executable with framework builds on macOS (GH-31958) 2022-04-05 02:05:36 -04:00
getpath.py gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542) 2022-05-06 01:34:11 +02:00
getpath_noop.c
grpmodule.c
hashlib.h
itertoolsmodule.c bpo-46728: fix docstring of combinations_with_replacement for consistency (GH-31293) 2022-02-15 09:02:21 +09:00
ld_so_aix.in
main.c gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542) 2022-05-06 01:34:11 +02:00
makesetup bpo-46023: makesetup: skip all duplicate modules (GH-32234) 2022-04-01 17:23:12 +02:00
makexp_aix
mathmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
md5module.c
mmapmodule.c bpo-46848: Move _PyBytes_Find() to internal C API (GH-31642) 2022-03-02 14:15:26 +01:00
nismodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
ossaudiodev.c gh-91734: Fix ossaudio support on Solaris (GH-91735) 2022-04-20 13:46:08 +03:00
overlapped.c gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
posixmodule.c gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
posixmodule.h
pwdmodule.c bpo-46670: Remove unused macros in the Modules directory (GH-31194) 2022-02-07 16:21:31 +01:00
pyexpat.c gh-91731: Replace Py_BUILD_ASSERT() with static_assert() (#91730) 2022-04-20 19:26:40 +02:00
readline.c
README
resource.c bpo-40280: Address more test failures on Emscripten (GH-31050) 2022-02-05 20:52:01 +01:00
rotatingtree.c
rotatingtree.h
selectmodule.c bpo-40280: select: Use NULL for empty fdset (GH-31865) 2022-03-14 14:40:28 +01:00
Setup
Setup.bootstrap.in bpo-47152: Move sources of the _sre module into a subdirectory (GH-32290) 2022-04-04 10:53:26 +03:00
Setup.stdlib.in bpo-45847: Port _tkinter to PY_STDLIB_MOD (GH-31698) 2022-03-31 03:19:08 -07:00
sha1module.c
sha256module.c
sha512module.c
signalmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
socketmodule.c gh-91968: Add socket constants SO_USER_COOKIE/SO_RTABLE from BSD (#91967) 2022-05-08 16:19:41 -07:00
socketmodule.h bpo-40280: Disable AF_UNIX, AF_PACKET, SO_REUSE* on Emscripten (#31829) 2022-03-11 23:25:14 +01:00
spwdmodule.c gh-91217: deprecate spwd (#91846) 2022-04-23 14:48:17 -07:00
symtablemodule.c
syslogmodule.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
termios.c
testcapi_long.h
timemodule.c bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898) 2022-03-15 21:55:35 +01:00
tkappinit.c
tkinter.h
unicodedata.c Remove usage of _Py_IDENTIFIER from unicodedata module. (GH-91532) 2022-04-15 10:44:05 +09:00
unicodedata_db.h
unicodename_db.h
winreparse.h
xxlimited.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
xxlimited_35.c
xxmodule.c
xxsubtype.c gh-91320: Use _PyCFunction_CAST() (#92251) 2022-05-03 21:42:14 +02:00
zlibmodule.c bpo-38256: Fix binascii.crc32() when inputs are 4+GiB (GH-32000) 2022-03-20 12:28:15 -07:00

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