cpython/Lib
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
..
asyncio Fix missing f prefix on f-strings (GH-91910) 2022-04-27 00:08:05 -07:00
collections Fix minor details in the Counter docs (GH-31029) (GH-31072) 2022-02-01 23:28:07 -06:00
concurrent [3.10] gh-90622: Do not spawn ProcessPool workers on demand via fork method. (GH-91598) (#92497) 2022-05-08 10:12:46 -07:00
ctypes [3.10] bpo-46913: Fix test_ctypes, test_hashlib, test_faulthandler on UBSan (GH-31675) 2022-03-04 01:12:06 +01:00
curses
dbm
distutils
email [3.10] gh-77630: Change Charset to charset (GH-92439) (GH-92476) 2022-05-08 08:28:06 -07:00
encodings [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
ensurepip Revert "bpo-46986: Upgrade bundled setuptools to 60.9.3 (GH-31820)" (GH-31880) 2022-03-14 17:08:28 -04:00
html Add source for character mappings (GH-92014) (#92389) 2022-05-06 12:58:16 +02:00
http bpo-46436: Fix command-line option -d/--directory in module http.server (GH-30701) 2022-02-14 12:12:30 -08:00
idlelib bpo-45447: Add syntax highlighting for .pyi files in IDLE (GH-28950) 2022-02-12 19:52:37 -05:00
importlib [3.10] bpo-47004: Sync with importlib_metadata 4.11.3. (GH-31854). (GH-31857) 2022-03-13 17:29:50 -04:00
json bpo-46001: Change OverflowError to RecursionError in JSON library docstrings (GH-29943) 2021-12-07 02:20:10 -08:00
lib2to3 bpo-46542: test_lib2to3 uses support.infinite_recursion() (GH-31035) 2022-01-31 12:03:40 -08:00
logging [3.10] bpo-42378: fixed log truncation on logging shutdown (GH-27310) (GH-30468) 2022-01-07 22:15:25 +00:00
msilib
multiprocessing bpo-47029: Fix BrokenPipeError in multiprocessing.Queue at garbage collection and explicit close (GH-31913) 2022-05-03 17:16:21 -07:00
pydoc_data Python 3.10.4 2022-03-23 20:12:04 +00:00
site-packages
sqlite3 [3.10] gh-80254: Disallow recursive usage of cursors in sqlite3 converters (#92274) 2022-05-05 12:46:21 -07:00
test Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582) 2022-05-14 08:01:53 -07:00
tkinter bpo-13553: Document tkinter.Tk args (GH-4786) 2022-05-09 21:27:37 -07:00
turtledemo
unittest [3.10] gh-91676 gh-91260 unittest.IsolatedAsyncioTestCase no longer leaks its executor (GH-91680) 2022-04-19 10:31:50 +01:00
urllib bpo-42627: Fix incorrect parsing of Windows registry proxy settings (GH-26307) 2022-05-12 01:21:39 +01:00
venv [3.10] bpo-43749: Ensure current exe is copied when using venv on windows (GH-25216) (GH-30034) 2021-12-10 17:51:42 +00:00
wsgiref
xml [3.10] gh-91810: ElementTree: Use text file's encoding by default in XML declaration (GH-91903) (GH-92664) 2022-05-11 10:39:21 -07:00
xmlrpc
zoneinfo
__future__.py
__phello__.foo.py
_aix_support.py
_bootsubprocess.py
_collections_abc.py [3.10] replace self param with more appropriate cls in classmethods (GH-31402) (GH-31446) 2022-02-20 15:45:13 +02:00
_compat_pickle.py
_compression.py
_markupbase.py
_osx_support.py
_py_abc.py
_pydecimal.py
_pyio.py bpo-25415: Remove confusing sentence from IOBase docstrings (PR-31631) 2022-03-04 10:33:57 -08:00
_sitebuiltins.py
_strptime.py
_threading_local.py
_weakrefset.py
abc.py
aifc.py
antigravity.py
argparse.py gh-91832: Add 'required' attr to argparse.Action repr (GH-91841) 2022-04-28 08:27:17 -07:00
ast.py
asynchat.py [3.10] bpo-47022: Document asynchat, asyncore and smtpd removals in 3.12 (GH-31891) (#31997) 2022-03-20 22:38:01 +02:00
asyncore.py [3.10] bpo-47022: Document asynchat, asyncore and smtpd removals in 3.12 (GH-31891) (#31997) 2022-03-20 22:38:01 +02:00
base64.py
bdb.py
binhex.py
bisect.py
bz2.py bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016) 2021-10-18 20:15:48 -07:00
calendar.py bpo-46266: Add calendar day of week constants to __all__ (GH-30412) (GH-30424) 2022-01-23 02:00:11 +01:00
cgi.py
cgitb.py
chunk.py
cmd.py
code.py
codecs.py
codeop.py [3.10] bpo-46521: Fix codeop to use a new partial-input mode of the parser (GH-31010). (GH-31213) 2022-02-08 12:25:15 +00:00
colorsys.py
compileall.py
configparser.py [3.10] bpo-45173: Note configparser deprecations will be removed in 3.12 (GH-31084) 2022-02-02 10:41:30 -08:00
contextlib.py
contextvars.py
copy.py bpo-45752: Remove "array" from list of things that cannot be copied in copy module docstring (GH-29555) 2021-11-14 05:18:31 -08:00
copyreg.py
cProfile.py
crypt.py
csv.py
dataclasses.py bpo-45663: Fix is_dataclass() for dataclasses which are subclasses of types.GenericAlias (GH-29294) 2021-12-05 13:04:29 -08:00
datetime.py Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582) 2022-05-14 08:01:53 -07:00
decimal.py
difflib.py Correct method name typo (GH-91970) 2022-04-27 15:19:43 -07:00
dis.py [3.10] bpo-45757: Fix bug where dis produced an incorrect oparg on EXTENDED_ARG before a no-arg opcode (GH-29480) (GH-29506) 2021-11-09 22:05:30 +00:00
doctest.py bpo-2604: Make doctest.DocTestCase reset globs in teardown (GH-31932) 2022-03-22 14:31:44 -07:00
enum.py bpo-44559: [Enum] restore fixes lost in 3.9 reversion (GH-29114) 2021-10-20 19:48:37 -07:00
filecmp.py
fileinput.py
fnmatch.py
fractions.py
ftplib.py
functools.py [3.10] bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050) (GH-30254) 2021-12-25 16:12:32 +02:00
genericpath.py
getopt.py
getpass.py
gettext.py
glob.py
graphlib.py
gzip.py bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016) 2021-10-18 20:15:48 -07:00
hashlib.py
heapq.py
hmac.py
imaplib.py
imghdr.py
imp.py
inspect.py bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' (GH-30285) (#30765) 2022-01-22 09:28:48 -08:00
io.py
ipaddress.py bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (GH-30642) 2022-05-03 05:37:17 -07:00
keyword.py
linecache.py
locale.py
lzma.py bpo-45475: Revert __iter__ optimization for GzipFile, BZ2File, and LZMAFile. (GH-29016) 2021-10-18 20:15:48 -07:00
mailbox.py
mailcap.py
mimetypes.py bpo-20392: Fix inconsistency with uppercase file extensions in mimetypes.guess_type (GH-30229) 2022-03-15 08:14:19 -07:00
modulefinder.py
netrc.py
nntplib.py
ntpath.py
nturl2path.py
numbers.py
opcode.py
operator.py
optparse.py
os.py
pathlib.py
pdb.py bpo-46434: Handle missing docstrings in pdb help (GH-30705) 2022-01-21 11:32:43 -08:00
pickle.py
pickletools.py
pipes.py
pkgutil.py
platform.py
plistlib.py
poplib.py
posixpath.py
pprint.py bpo-45557: Fix underscore_numbers in pprint.pprint(). (GH-29129) 2021-10-21 14:16:59 -07:00
profile.py
pstats.py
pty.py
py_compile.py bpo-45428: Fix reading filenames from stdin in py_compile (GH-28848) 2021-10-15 05:14:35 -07:00
pyclbr.py
pydoc.py [3.10] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976) 2022-03-18 20:46:31 +02:00
queue.py gh-90879: Fix missing parameter for put_nowait() (GH-91514) 2022-04-14 02:18:31 -07:00
quopri.py
random.py
re.py
reprlib.py
rlcompleter.py
runpy.py bpo-26792: Improve docstrings of runpy module run_functions (GH-30729) 2022-04-29 11:45:43 -07:00
sched.py
secrets.py
selectors.py
shelve.py
shlex.py
shutil.py gh-88513: clarify shutil.copytree's dirs_exist_ok arg (GH-91434) (GH-91464) 2022-04-15 15:55:13 +02:00
signal.py [3.10] bpo-27718: Fix help for the signal module (GH-30063) (GH-30080) 2021-12-13 12:14:51 +02:00
site.py
smtpd.py [3.10] bpo-47022: Document asynchat, asyncore and smtpd removals in 3.12 (GH-31891) (#31997) 2022-03-20 22:38:01 +02:00
smtplib.py
sndhdr.py
socket.py
socketserver.py
sre_compile.py [3.10] gh-91575: Update case-insensitive matching in re to the latest Unicode version (GH-91580). (GH-91661) 2022-04-22 21:44:05 +03:00
sre_constants.py [3.10] gh-92049: Forbid pickling constants re._constants.SUCCESS etc (GH-92070) (GH-92073) 2022-04-30 15:33:39 +03:00
sre_parse.py [3.10] gh-91700: Validate the group number in conditional expression in RE (GH-91702) (GH-91831) 2022-04-22 21:09:30 +03:00
ssl.py bpo-46604: fix function name in ssl module docstring (GH-31064) 2022-05-03 09:24:39 -07:00
stat.py
statistics.py Fix double-space in exception message (GH-29955) 2021-12-08 03:07:27 -08:00
string.py
stringprep.py
struct.py
subprocess.py [3.10] gh-91401: Conservative backport of subprocess._USE_VFORK (#91932) 2022-05-01 16:09:50 -07:00
sunau.py
symtable.py
sysconfig.py
tabnanny.py
tarfile.py bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693) 2022-02-09 09:31:12 -08:00
telnetlib.py
tempfile.py bpo-45192: Fix a bug that infers the type of an os.PathLike[bytes] object as str (GH-28323) (GH-29111) 2021-10-20 23:27:30 +02:00
textwrap.py
this.py
threading.py
timeit.py
token.py
tokenize.py
trace.py
traceback.py bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726) (GH-29826) 2021-11-29 10:07:24 +00:00
tracemalloc.py
tty.py
turtle.py bpo-45837: Note tiltangle is not deprecated, it's really settiltangle (GH-29629) 2021-11-19 19:55:40 +01:00
types.py bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298) 2021-12-05 13:26:37 -08:00
typing.py [3.10] bpo-46581: Propagate private vars via _GenericAlias.copy_with (GH-31061) (GH-31821) 2022-03-11 16:57:52 +02:00
uu.py
uuid.py
warnings.py
wave.py
weakref.py
webbrowser.py
xdrlib.py
zipapp.py
zipfile.py bpo-42369: Fix thread safety of zipfile._SharedFile.tell (GH-26974) 2022-03-20 07:51:11 -07:00
zipimport.py