Update stdlib for Python 3.15#15714
Conversation
# Conflicts: # stdlib/_interpqueues.pyi # stdlib/ast.pyi # stdlib/base64.pyi # stdlib/collections/__init__.pyi # stdlib/glob.pyi # stdlib/importlib/metadata/__init__.pyi # stdlib/pyexpat/__init__.pyi # stdlib/sys/__init__.pyi # stdlib/threading.pyi # stdlib/types.pyi # stdlib/typing.pyi # stdlib/unicodedata.pyi # stdlib/unittest/_log.pyi # stdlib/unittest/case.pyi # stdlib/wave.pyi # stdlib/zipimport.pyi
This comment has been minimized.
This comment has been minimized.
|
I would like to get the testing infrastructure for 3.15 up before adding 3.15 branches. It also doesn't fill me with confidence that we already have stubtest errors without even testing 3.15. |
|
Here's my suggestion on how to move forward:
|
| from typing_extensions import Self, disjoint_base | ||
|
|
||
| if sys.version_info >= (3, 15): | ||
| from builtins import frozendict as frozendict |
There was a problem hiding this comment.
Do we really want to re-export frozendict from collections?
| if sys.platform != "win32": | ||
| abiflags: str | ||
| if sys.version_info >= (3, 15): | ||
| abi_info: SimpleNamespace |
There was a problem hiding this comment.
It would be nice to type the fields as well:
>>> import sys
>>> sys.abi_info
namespace(pointer_bits=64, free_threaded=False, debug=True, byteorder='little')|
Hi! There's one new addition in 3.15 which I notice is missing from the release notes and the current PR: I guess if the What's New is up to date there shouldn't be a problem for the AI but maybe there are other changes also missing? |
|
wave.open: Yes, I had it look only at the What's New. I think we're liable to miss such changes to only allowed parameter types, because there's no automatic way to check them; I wouldn't be surprised if we similarly missed some changes for earlier versions. Maybe I'll try making an AI look at the whole diff between 3.14 and 3.15 and flag things that were missed. Point taken on getting CI set up first, I'll do that. The stubtest failures seem to be mostly from changes that were made unconditionally that should have been made conditional on version. |
|
My plan now:
|
I'll try to prioritize reviewing. If it's just small, straight-forward changes, I'm fine with larger PRs. It's more about the amount if lines and the complexity than the amount of modules. |
|
|
||
| class Collector(ABC): | ||
| def collect(self, stack_frames, timestamps_us=None) -> None: ... | ||
| def collect(self, stack_frames: Any, timestamps_us: Any | None = None) -> None: ... |
There was a problem hiding this comment.
these should just be left unannotated I think (same for a bunch of others in this file)
This comment has been minimized.
This comment has been minimized.
# Conflicts: # stdlib/@tests/stubtest_allowlists/darwin-py315.txt # stdlib/@tests/stubtest_allowlists/linux-py315.txt # stdlib/@tests/stubtest_allowlists/py315.txt # stdlib/@tests/stubtest_allowlists/win32-py315.txt # stdlib/_collections_abc.pyi # stdlib/_socket.pyi # stdlib/_ssl.pyi # stdlib/binascii.pyi # stdlib/builtins.pyi # stdlib/calendar.pyi # stdlib/collections/__init__.pyi # stdlib/datetime.pyi # stdlib/difflib.pyi # stdlib/hashlib.pyi # stdlib/mmap.pyi # stdlib/platform.pyi # stdlib/re.pyi # stdlib/resource.pyi # stdlib/socket.pyi # stdlib/sqlite3/__init__.pyi # stdlib/typing.pyi # stdlib/unittest/_log.pyi # stdlib/wave.pyi
|
|
||
| if sys.version_info >= (3, 15): | ||
| from builtins import frozendict | ||
| from builtins import frozendict as _frozendict |
There was a problem hiding this comment.
change in this file is just busywork now, I'll make sure not to put it in any split-off PRs
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Part of #15709.
I pointed Codex at the What's New for 3.15 and told it to apply every change relevant to typeshed, then told it to get stubtest running on 3.15 (which found python/cpython#149504) and fix the remaining issues. I also reviewed manually and made a few adjustments (including noticing python/cpython#149534).
I'm not sure about the way it approached
urllib.parseand I might redo that, but mostly this appears to be correct.I also had it make a list of all the changes with relevant PRs and links to the CPython code:
builtins.frozendictand allowed it instr.maketrans,eval, andexecglobals (CPython PR: PEP 814: Add built-in frozendict type cpython#141510; source: https://github.com/python/cpython/blob/main/Objects/dictobject.c)builtins.sentinel(CPython PR: Implement PEP 661 Sentinel Values cpython#148829; source: https://github.com/python/cpython/blob/main/Objects/sentinelobject.c)bytearray.take_bytes(CPython PR: Add.take_bytes([n])a zero-copy path frombytearraytobytescpython#139871; source: https://github.com/python/cpython/blob/main/Objects/bytearrayobject.c)slice(already present upstream; CPython PR: Make slice generic cpython#128335; source: https://github.com/python/cpython/blob/main/Objects/sliceobject.c)argparsesuggest_on_errorandcolorparameters, changed the 3.15suggest_on_errordefault, removedHelpFormatter(color=...), and added formatter parameters toArgumentParser.format_usage(),format_help(), and_get_formatter()(CPython PR: gh-140448: Defaultsuggest_on_errortoTrueinargparse.ArgumentParsercpython#140450; source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/argparse.py)arraytypecodes for half-precision and complex arrays and widenedarray.typecodes(CPython PRs: Support half-floats in the array module cpython#146238, Add support for numpy buffer formatZfandZdcpython#148675; source: https://github.com/python/cpython/blob/main/Modules/arraymodule.c)ast.dump(color=...)(CPython PR: Add colour toast.dumpoutput cpython#148981; source: https://github.com/python/cpython/blob/main/Lib/ast.py)ast.Import.is_lazyandast.ImportFrom.is_lazyfor lazy imports (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Parser/Python.asdl)asyncio.tools.display_awaited_by_tasks_table(retries=...)anddisplay_awaited_by_tasks_tree(retries=...)(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/asyncio/tools.py)asyncio.TaskGroup.cancel(CPython PR: gh-108951: add TaskGroup.cancel() cpython#127214; source: https://github.com/python/cpython/blob/main/Lib/asyncio/taskgroups.py)ignorecharsfor hex decoding (CPython PRs: Option to skip padding for base64 urlsafe encoding/decoding cpython#73613, Support multiline output in binascii.b2a_base64() and base64.b64encode() cpython#143214, Add the ignorechars parameter in the Base64 decoder cpython#144001, binascii base64 & base32 decode ignore excess padding bits in their input cpython#146311, base64.z85encode should have "pad" parameter cpython#143103, C accelerator for Base32 character encoding cpython#146192, base64.b85encode uses significant amount of RAM cpython#101178, Support alternative alphabets in BaseXX encodings cpython#145980; source: https://github.com/python/cpython/blob/main/Modules/binascii.c)builtins.ImportCycleErrorandbuiltins.__lazy_import__for lazy imports (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Python/bltinmodule.c)calendar.standalone_month_name,calendar.standalone_month_abbr, andHTMLCalendar.formatmonthpage()(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/calendar.py)collections.Countersymmetric difference operators (CPython PR: Add symmetric_difference to Counter cpython#138682; source: https://github.com/python/cpython/blob/main/Lib/collections/__init__.py)cProfile.labelfrom the 3.15 runtime surface (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/cProfile.py)dbm.dumb._Database.reorganize,dbm.sqlite3.REORGANIZE,dbm.sqlite3._Database.reorganize,shelve.ShelveError, andshelveserializer/deserializer keyword-only parameters (CPython PRs: DBM Module Vacuuming cpython#134004, Custom unpickler and pickler for the shelve module cpython#99631; sources: https://github.com/python/cpython/blob/main/Lib/dbm/dumb.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/dbm/sqlite3.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/shelve.py)decimal.SPEC_VERSION,_decimal.SPEC_VERSION, and_pydecimal.SPEC_VERSION(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/_pydecimal.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_decimal/_decimal.c)datetimeISO/strptime positional-only parameters tostring(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_datetimemodule.c)difflib.unified_diff(color=...)(CPython PR: gh-133722: Add Difflib theme to_colorizeand 'color' option todifflib.unified_diffcpython#133725; source: https://github.com/python/cpython/blob/main/Lib/difflib.py)faulthandlermax_threadsparameters (CPython PR: faulthandler: make per-call thread dump cap configurable cpython#149085; source: https://github.com/python/cpython/blob/main/Modules/faulthandler.c)genericpath.ALL_BUT_LAST,posixpath.ALL_BUT_LAST, andntpath.ALL_BUT_LAST, and updated several path helpers to positional-only signatures (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/genericpath.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/posixpath.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/ntpath.py)hashlib.scrypttohashlib.__all__for Python 3.15 (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/hashlib.py)http.client.HTTPConnection(max_response_headers=...)andHTTPSConnection(max_response_headers=...)(CPython PR: http.client._MAXHEADERS = 100 limit no longer sufficient cpython#131724; source: https://github.com/python/cpython/blob/main/Lib/http/client.py)http.serverdefault_content_typeandSimpleHTTPRequestHandler(extra_response_headers=...); removedCGIHTTPRequestHandlerfor 3.15 (CPython PRs: default http content-type cpython#113471, gh-135056: Add a --header CLI argument to http.server cpython#135057, Removehttp.server.CGIHTTPRequestHandlerand--cgiflag support cpython#133810; source: https://github.com/python/cpython/blob/main/Lib/http/server.py)inspect.getdoc(inherit_class_doc=..., fallback_to_class_doc=...)(CPython PR: Share code for getdoc() between inspect and pydoc cpython#132686; source: https://github.com/python/cpython/blob/main/Lib/inspect.py)importlib.resources.abc.Traversable.read_text(errors=...)(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/importlib/resources/abc.py)importlib.metadata.DeprecatedNonAbstract, keptDistributionandPathDistributionas ABCs, and updated 3.15importlib.metadata.__all__/MetadataNotFound(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/importlib/metadata/__init__.py)json.loadandjson.loadsarray_hook(CPython PR: Add "array_hook" parameter to JSON decoder cpython#146440; source: https://github.com/python/cpython/blob/main/Lib/json/__init__.py)json.decoder.JSONDecoder(array_hook=...)and_json.make_scanner.array_hook; changed_json.scanstringto the 3.15 positional-onlypystr, end, strictsignature (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/json/decoder.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_json.c)math.integerand newmathfloating-point predicates/helpers (CPython PRs: PEP-791: Add a module for integer related math functions cpython#81313, Have math.isnormal() and, perhaps, math.issubnormal()? cpython#132908, Decide the fate of missing C99 functions inmathcpython#135853; source: https://github.com/python/cpython/blob/main/Modules/mathmodule.c)mmap.mmap(trackfd=...)on Windows,mmap.mmap.flush(flags=...),mmap.mmap.set_name(), and 3.15 optionalNonebounds forfind(),rfind(), andmadvise(); removedmmap.mmap.resize()on Darwin (source: https://github.com/python/cpython/blob/main/Modules/mmapmodule.c)opcode.opmaptofrozendictand addedpathlib.PurePath.__vfspath__()for Python 3.15 (CPython sources: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/opcode.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/pathlib/__init__.py)profiling,profiling.tracing, andprofiling.samplingmodules (source: https://github.com/python/cpython/tree/main/Lib/profiling)pstats.Stats.print_call_subheading()andpydoc.Doc.STDLIB_DIR; changedpydoc.Doc.getdocloc(basedir=None)(CPython sources: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/pstats.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/pydoc.py)pyexpat.XMLParserType.SetBillionLaughsAttackProtectionActivationThreshold()andSetBillionLaughsAttackProtectionMaximumAmplification()(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/pyexpat.c)_interpqueues.create(maxsize, unboundop=-1, fallback=-1)and_interpqueues.put(qid, obj, unboundop=-1, fallback=-1)signatures (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_interpqueuesmodule.c)re.prefixmatchandPattern.prefixmatch(CPython PR: Proposal: re.prefixmatch method (alias for re.match) cpython#86519; source: https://github.com/python/cpython/blob/main/Lib/re/__init__.py)resourceconstantsRLIMIT_NTHR,RLIMIT_UMTXP,RLIMIT_THREADS,RLIM_SAVED_CUR, andRLIM_SAVED_MAX(CPython PR: Add more RLIMIT_* constants cpython#137512; source: https://github.com/python/cpython/blob/main/Modules/resource.c)symtable.Function.get_cellsandsymtable.Symbol.is_cell(CPython PR: expose CELL status of a symbol in symtable cpython#143504; source: https://github.com/python/cpython/blob/main/Lib/symtable.py)sys.abi_infoand lazy import configuration APIs (CPython PRs: Implement PEP 810 – Explicit lazy imports cpython#142349, gh-133143: Make information about the interpreter ABI more accessible cpython#137476; source: https://github.com/python/cpython/blob/main/Python/sysmodule.c)check_homeparameter fromsysconfig.is_python_build()(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/sysconfig/__init__.py)sqlite3.SQLITE_KEYWORDSand_sqlite3.SQLITE_KEYWORDS; updated severalsqlite3.Connectioncallback registration methods to positional-only parameters (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_sqlite/module.c, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Modules/_sqlite/clinic/connection.c.h)stat.STATX_ATTR_*constants for Linux statx attributes (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/stat.py)timeit.Timer.autorange(target_time=...)(CPython PR: timeit: Additional changes for autorange cpython#80642; source: https://github.com/python/cpython/blob/main/Lib/timeit.py)threading.serialize_iterator,threading.synchronized_iterator, andthreading.concurrent_tee(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/threading.py)tkinter.Event.detail,Event.user_data,*_contentgeometry methods, and text search options/APIs (CPython PRs: gh-130693: Add options of the tkinter.Text.search method: -nolinestop -all -overlap -strictlimits cpython#130848,tkintersource and docs use the word 'slave' cpython#143754, Add support for the new data option supported by event generate (Tk 8.5) cpython#47655; source: https://github.com/python/cpython/blob/main/Lib/tkinter/__init__.py)tarfile.TarFile.__init__(mtime=...)(CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/tarfile.py)types.FrameLocalsProxyType,types.LazyImportType, 3.15FrameType.f_locals, and generator/coroutine state properties (gi_state,cr_state,ag_state); removedCodeType.co_lnotabfor 3.15 (CPython PR: Remove deprecatedco_lnotabfromCodeTypecpython#134690; source: https://github.com/python/cpython/blob/main/Objects/frameobject.c, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Objects/genobject.c)typing.TypeFormandtyping.disjoint_base; removedtyping.no_type_check_decoratorandtyping.ByteStringfromtyping.__all__for 3.15; updatedTypeVarTupleconstructor surface (CPython PRs: Implement PEP 747: TypeForm cpython#145033, Implement PEP 800: typing.disjoint_base cpython#148639, Remove deprecatedtyping.no_type_check_decoratorcpython#133601; source: https://github.com/python/cpython/blob/main/Lib/typing.py)typing.NoExtraItemsandtyping.TypeAliasType.__qualname__for Python 3.15 (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/typing.py, https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Objects/typevarobject.c)collections.abc.ByteStringfromcollections.abc.__all__for 3.15 (source: https://github.com/python/cpython/blob/main/Lib/_collections_abc.py)unicodedata.block,unicodedata.extended_pictographic,unicodedata.grapheme_cluster_break,unicodedata.indic_conjunct_break,unicodedata.isxidstart,unicodedata.isxidcontinue, andunicodedata.iter_graphemes(start=..., end=...)(CPython PRs: unicodedata module needs way of accurately determining XID_START and XID_CONTINUE properties. cpython#129117, Add unicode grapheme cluster break algorithm cpython#74902, Add block info to unicodedata cpython#66802; source: https://github.com/python/cpython/blob/main/Modules/unicodedata.c)unittest.TestCase.assertLogs(formatter=...)(CPython PR: Expose log format to users in assertLogs cpython#134567; source: https://github.com/python/cpython/blob/main/Lib/unittest/case.py)warnings.WarningMessage(module=...)and.moduleattribute (CPython source: https://github.com/python/cpython/blob/e81025e6d2e01e38c5a5b656af5739ac9df5ff55/Lib/_py_warnings.py)urllib.parsemissing_as_noneandkeep_emptyoptions (CPython PR: urllib.parse wrongly strips empty #fragment, ?query, //netloc cpython#67041; source: https://github.com/python/cpython/blob/main/Lib/urllib/parse.py)wave.WAVE_FORMAT_IEEE_FLOAT,getformat,setformat, and 7-field params; removed marker methods for 3.15 (CPython PRs: wave file module does not support 32bit float format cpython#60729, Remove deprecated mark interface forwave.Wave_{read,write}classes cpython#133873; source: https://github.com/python/cpython/blob/main/Lib/wave.py)xml.is_valid_nameandxml.is_valid_text(CPython PR: Add utility functions to test for legal XML characters and names cpython#139489; source: https://github.com/python/cpython/blob/main/Lib/xml/__init__.py)zlib.adler32_combineandzlib.crc32_combine(CPython PR: Exportzlib.{adler,crc}32_combinecpython#134635; source: https://github.com/python/cpython/blob/main/Modules/zlibmodule.c)glob.glob0,glob.glob1,platform.java_ver,pathlib.PurePath.is_reserved, andzipimport.zipimporter.load_modulefor 3.15 (sources: https://github.com/python/cpython/blob/main/Lib/glob.py, https://github.com/python/cpython/blob/main/Lib/platform.py, https://github.com/python/cpython/blob/main/Lib/pathlib/__init__.py, https://github.com/python/cpython/blob/main/Lib/zipimport.py)sre_compile,sre_constants, andsre_parsemodules for 3.15 (source: https://github.com/python/cpython/tree/main/Lib)