Up to [cvs.NetBSD.org] / pkgsrc / lang / python313 / patches
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
python313 py313-html-docs: updated to 3.13.15 Python 3.13.15 macOS gh-153711: On macOS, do not attempt to use the dup3(2) and pipe2(2) system calls introduced in macOS 27 to prevent problems when running on older systems. Windows gh-140146: Prevent tkinter from hanging on Windows if stdin is redirected to a pipe in an interactive session. This is helpful for testing interactive usage of tkinter from a script, for example as part of the cpython test suite. Tools/Demos gh-155218: Fix Argument Clinic generating the flags of the optional groups in different order on 32-bit and 64-bit platforms. gh-155207: Argument Clinic now supports the --dry-run and --diff options. They list the files which would be changed, or write a unified diff of the changes to the standard output, without modifying any file. gh-64502: Fix Argument Clinic support of parameters with a default value used together with optional groups. Such parameters were always required in the generated parsing code. gh-154580: Fix python-gdb.py raising UnicodeEncodeError when pretty-printing a non-ASCII str in a locale whose host charset cannot encode it, such as any non-ASCII string in the C locale. Tests gh-76595: Add C API tests for PyCapsule_Import(). gh-154167: The test runner (regrtest) now restores the default SIGINT handler if it was inherited as ignored, so the test suite no longer hangs when run as a shell background job. gh-154144: Fix building the _testcapi module on NetBSD. gh-152548: Add the test.support.isolation.runInSubprocess() decorator to run a test method or TestCase subclass in a fresh interpreter subprocess, isolated from the rest of the test run. gh-151626: Fix several tests in test.test_inspect, test.test_import, test.test_importlib, test.test_py_compile and test.test_compileall that failed when the test suite was run with PYTHONPYCACHEPREFIX set. These tests now neutralize the pycache prefix where they assume the default __pycache__ bytecode layout. gh-151096: Fix test_embed failing when CPython is configured with a split exec prefix (--exec-prefix differing from --prefix). Security gh-153030: Fixed quadratic complexity in incremental parsing of long unterminated constructs (such as tags or comments) in html.parser.HTMLParser, which could be exploited for a denial of service. gh-152674: The xml.etree.ElementTree.Element methods findall(), iterfind() and find() avoid quadratic behavior when using XPath index predicates ([1], [last()], [last()-N]) on XML documents with many same-tag siblings. gh-152216: Update bundled libexpat to version 2.8.2. gh-151987: The tarfile.TarFile.extract() method now applies the given filter when it extracts a link target from the archive as a fallback. gh-151981: In tarfile, seeking a stream now stops when end of the stream is reached. gh-151544: Modules/Setup.local is no longer used as a landmark to discover whether Python is running in a source tree, as it could potentially affect actual installs. The pybuilddir.txt file is now the sole indicator of running in a source tree. gh-151558: Fixed an vulnerability in the tarfile data and tar extraction filters where crafted archives could create a symlink pointing outside the destination directory. This was a bypass of CVE 2025-4330. gh-150743: http.client now limits the number of chunked-response trailer lines it will read to 100, and the number of interim (1xx) responses it will skip to 100. A malicious or broken server could previously stream trailer lines or 100 Continue responses forever, hanging the client even when a socket timeout was in use. Reported by @YLChen-007 via GHSA-w4q2-g22w-6fr4. gh-143927: Normalize all line endings (CR, CRLF, and LF) to LF+TAB when writing multi-line configparser values. gh-143921: Reject NUL, CR and LF characters in IMAP commands. Other control characters are allowed and sent quoted. Library gh-155063: Bump the version of pip bundled in ensurepip to version 26.2.1 gh-155063: Bump the version of pip bundled in ensurepip to version 26.2 gh-154936: Fix the pure Python json decoder to report the correct position for invalid literal control characters in JSON strings. gh-154892: Fix a bug in the C accelerator for zoneinfo where datetime.datetime subclasses returning -1 for hour, minute, or second could incorrectly raise a SystemError. gh-154871: Fixed a crash in asyncio.Task.get_context() when called on an uninitialized task. gh-154848: The pickle C accelerator now enforces frame boundaries when unpickling, as the pure Python implementation already did. An argument that straddles a frame boundary, or a frame that begins before the previous one has ended, now raises pickle.UnpicklingError instead of being silently read across the boundary. This prevents the loaded data from diverging from the pickletools disassembly of the same pickle. gh-109638: Fix exponential time in csv.Sniffer.sniff() for a sample which contains many quote characters. A doubled quote character is now also detected in a field which contains the delimiter or a line break. gh-98820: Fix quadratic time in csv.Sniffer.sniff() for a sample which contains quoted fields, in particular for a single column of quoted fields. gh-154738: Fix ExternalEntityParserCreate() not propagating the reparse-deferral setting to the subparser, which left GetReparseDeferralEnabled() returning an uninitialized value. Patch by tonghuaroot. gh-93251: Fix UnicodeDecodeError in socket functions (such as getaddrinfo() and gethostbyaddr()) when the localized error message of the C library is not UTF-8: decode it from the locale encoding. gh-154551: Fix ctypes.util.find_library() returning None in non-UTF-8 locales. gh-79366: Fixed a race condition in logging: if a handler was removed while a record was being emitted, the following handlers of the same logger could be skipped. gh-73458: Fix logging.config.listen(): it left the caller waiting for the ready event forever if the server could not be started, for example if the port was invalid or already in use. It now also binds to an IPv6 address if the host has no IPv4 address, for example if localhost is only aliased to ::1. gh-154460: Fix time.strftime() and datetime.datetime.strftime() returning a wrong ISO 8601 week number (%V) on OpenBSD. gh-154435: Fix os.posix_fadvise() and os.posix_fallocate() on DragonFly BSD: they raised OSError with a meaningless error code, because these functions return -1 and set errno there. gh-154399: Fix venv activation in a non-interactive csh: activate.csh no longer fails when the prompt variable is not set. gh-154389: Fix uuid.uuid1() on OpenBSD: it returned a version 4 UUID, because uuid_create() generates random UUIDs on this platform. gh-154324: Fix os.sendfile() on illumos: it no longer reports a successful transfer when the underlying system call failed without writing any data. gh-154307: Fix tempfile.TemporaryDirectory.cleanup() on DragonFly BSD, where removing a file with the UF_NOUNLINK flag failed with EISDIR instead of EPERM. gh-154291: Fix socket.has_dualstack_ipv6() to return False on platforms such as DragonFly BSD where setting IPV6_V6ONLY to 0 silently has no effect. gh-154283: On DragonFly BSD, threading.get_native_id() now returns a value that is unique across processes, matching the other platforms. gh-154258: Fix a crash in mmap.mmap.resize() on NetBSD when growing a shared anonymous mapping. resize() now raises ValueError in this case, as it already did on Linux. gh-154225: Fix os.openpty() on Solaris and illumos: it no longer leaves the pseudo-terminal as the controlling terminal of the calling process. gh-154227: Fix os.posix_openpt() on OpenBSD, where it rejected the O_CLOEXEC flag. gh-145030: Fix asyncio write pipe transports for named FIFOs on macOS and Solaris. Unread data sitting in the FIFO made the transport misinterpret a poll event as the reader disconnecting, wrongly closing the transport. gh-154001: Fix random.binomialvariate() raising ZeroDivisionError when random.random() returns zero. gh-153896: Deduplicate unhashable args in typing.Literal. gh-153864: On a wide curses build, curses.window.insch() now inserts a non-ASCII byte as the character it encodes in the window’s encoding, consistently with addch(), instead of its code point. gh-153862: On a wide curses build, curses.window.inch() now returns the locale-encoded byte of a non-ASCII character, matching instr(), instead of the low byte of its code point. gh-146011: Fix a heap-use-after-free in the C implementation of decimal when calling repr() after deleting the Context. gh-153761: Fix cancelling asyncio.loop.sock_accept() dropping a pending connection. gh-153695: Hashing a sqlite3.Row that contains an unhashable value now raises TypeError instead of SystemError. Patch by tonghuaroot. gh-153658: Fix sqlite3.Connection.iterdump() raising sqlite3.OperationalError when a table name contains a single quote. Patch by tonghuaroot. gh-85943: Fix struct functions raising BytesWarning under the -bb command line option when a str format is used after an equal bytes format (or vice versa). The internal format cache no longer mixes str and bytes keys. gh-153404: urllib.robotparser.RobotFileParser now silently ignores a Crawl-delay or Request-rate value written with non-decimal digits (such as U+00B2 SUPERSCRIPT TWO) instead of raising ValueError and aborting the parse of the whole robots.txt file. gh-153417: Error messages from imaplib.IMAP4.select() and imaplib.IMAP4.uid() no longer raise BytesWarning under -bb when the mailbox or command argument is bytes. gh-153406: email.utils.parsedate_to_datetime() now raises ValueError instead of OverflowError when the parsed year or timezone offset is out of range, matching its documented behavior. gh-153083: Defer GC tracking of an array.array to the end of its construction. Patch by Donghee Na. gh-143990: A tkinter.font.Font created from a named font, including by copy(), now copies its configured options rather than the options resolved by Tcl’s font actual, preserving a size specified in pixels (a negative size). gh-153210: Fix crash on array import under a memory pressure. gh-153200: Fix math.isqrt() returning an incorrect result for arguments not less than 2**64 that are instances of an int subclass with an overridden comparison operator. gh-153068: Fix cProfile.Profile.enable() to no longer overwrite errors from sys.monitoring. gh-153056: Fix string.Template raising a spurious ValueError when the pattern attribute is a compiled regular expression object, which the documentation allows. gh-135661: Fix html.parser.HTMLParser: an abruptly closed empty comment (<!--> or <!--->) no longer extends up to a later --> in the same feed() call. gh-54930: Error responses of http.server.BaseHTTPRequestHandler to malformed request lines now include a status line and headers instead of being sent in the bare HTTP/0.9 style. Only a valid HTTP/0.9 request (a two-word GET request line) now receives an HTTP/0.9 style response. gh-152951: collections.deque prevent rare crash when calling extend under high memory pressure conditions. gh-150880: Normalize non-extended Windows paths before appending the wildcard used by os.listdir() and os.scandir(), making paths with trailing spaces behave consistently with other filesystem APIs. gh-152849: Out-of-range float and integer timestamps now raise OverflowError with the same message. Patch by tonghuaroot. gh-152847: Reject a POSIX TZ transition rule with non-digit characters in the day-of-year field in the pure-Python zoneinfo parser. Patch by tonghuaroot. gh-108280: Connecting imaplib to a server that does not send a valid IMAP4 greeting (for example a POP3 server answering on the IMAP port) now raises an error reporting the server’s response instead of imaplib.IMAP4.error: None. gh-151126: Fix a crash caused by failing to set MemoryError on allocation failure when passing ctypes.Structure or ctypes.Union instances by value to ctypes foreign functions. gh-63121: imaplib now refreshes the cached capability list after a successful login() or authenticate(), using the CAPABILITY response sent by the server or, if none was sent, by querying it, so that capabilities that become available only after authentication (such as ENABLE on Gmail) are recognized. Capabilities advertised in the server greeting are now also used, avoiding a redundant CAPABILITY command. gh-88574: imaplib no longer fails when a server sends a spurious blank line after the counted data of a literal, including after a literal that terminates a response (such as a mailbox name returned by LIST). Such blank lines are now skipped without swallowing the following line. gh-152502: Detect the curses mouse interface (getmouse(), the BUTTON* constants, and others) with a configure capability probe or library macros instead of gating it on ncurses-specific macros. It is now also available with other curses implementations that provide it, such as NetBSD curses and PDCurses (the latter underpins windows-curses). gh-40038: imaplib now again quotes command arguments when necessary, for example mailbox names containing a space. Such quoting was inadvertently disabled when the module was ported to Python 3, and the arguments are now quoted according to the RFC 3501 grammar. For backward compatibility, an argument already enclosed in double quotes is left unchanged, so code that quotes arguments itself keeps working. gh-50966: Fix unbounded recursion in turtle when a mouse event handler that moves the turtle is reentered while the screen is being redrawn, for example with screen.ondrag(turtle.goto). This could previously crash the interpreter. gh-78335: Update the docstrings of tkinter and tkinter.ttk widget classes to list all supported widget options, including options added in Tk 9.0 and 9.1. tkinter.Menubutton and tkinter.Message previously had no option list at all. gh-151126: Fix two crashes in tkinter and socket modules initialization under a memory pressure. Sets missing MemoryError. gh-133031: curses.textpad.Textbox now enters and reads back the non-ASCII characters of an 8-bit locale encoding, instead of mangling them with a 7-bit mask. gh-71880: curses.textpad.Textbox now lets the lower-right cell of the window be edited. Writing it with addch() would move the cursor past the end of the window, raising an error and scrolling a scrollable window, so it is now written with insch(), which keeps the cursor in place. gh-83274: Deallocating a tkinter application from a thread other than the one it was created in no longer crashes the interpreter. The underlying Tcl interpreter is leaked instead, and a RuntimeWarning is reported. gh-88758: tkinter.Misc.focus_get(), focus_displayof(), focus_lastfor() and winfo_containing() now return None instead of raising KeyError when the widget was not created by tkinter (for example a torn-off menu). gh-38464: tkinter.Misc.nametowidget() now resolves the auto-generated names of cloned menus (a menu used as a menubar or a cascade) back to the original widget. gh-152248: Make the C and pure-Python zoneinfo parsers validate POSIX TZ abbreviations consistently, rejecting unquoted abbreviations with non-letter characters and empty quoted abbreviations. Patch by tonghuaroot. gh-80937: Fix a memory leak in tkinter when a Tcl command created with createcommand was not explicitly removed before the interpreter was deleted. The command no longer keeps the interpreter alive through a reference cycle. gh-152246: Fix the pure-Python zoneinfo parser accepting an invalid POSIX TZ transition rule with a non-period separator. Patch by tonghuaroot. gh-139816: Fix a hang in tkinter on interactive Python built without readline. An exception raised in a callback no longer causes the event loop to stop and wait for the user to press Enter; pending callbacks now keep running until input is actually available on stdin. gh-139145: Fix a busy loop in tkinter on interactive Python. When a Tcl command running its own event loop (such as vwait or wait_variable()) was active and input arrived on stdin, the event loop kept spinning at 100% CPU. The stdin file handler is now removed as soon as input is available. Based on a patch by Michiel de Hoon. gh-152212: Fix the pure-Python zoneinfo parser accepting a POSIX TZ string with a std abbreviation but no offset. This is invalid per POSIX and now raises ValueError, matching the C accelerator. Patch by tonghuaroot. gh-152156: Fix a possible crash in _interpreters.create() under limited memory conditions. gh-152157: The C implementations of fromisoformat() and fromisoformat() now reject a decimal separator that is not followed by any fractional digit before a timezone designator. gh-151763: Fix crash in _interpqueues.create() whe MemoryError happens on queue creation. gh-105895: Add match and case to the list of supported topics by help(). gh-152079: Fix datetime.datetime.fromisoformat() in the C implementation dropping the sub-second part of a UTC offset whose whole-second part is zero, matching the pure-Python implementation. gh-152052: The json C accelerator now correctly reports an unterminated string for a \uXXXX escape at the end of the input. gh-152060: Fix datetime.datetime.fromisoformat() raising AssertionError instead of ValueError for some malformed strings in the pure-Python implementation, matching the C implementation. gh-126219: Fixed a crash in tkinter.Tk when className contains a non-BMP character and tkinter is built against Tcl/Tk 8.x. Such a name is now rejected with a ValueError. gh-151955: Allow more types to be used in the bound argument to typing.ParamSpec. gh-86165: Fix imaplib.Time2Internaldate() to use the local timezone offset for time.struct_time values with tm_gmtoff set to None, as returned by datetime.datetime.timetuple(). Contributed by Xiao Yuan. gh-151814: Fix unbounded memory growth in io.TextIOWrapper when repeatedly writing an empty string. gh-151695: Fix a use-after-free in the curses module. The encoding of the initial screen, used by curses.unctrl() and curses.ungetch() to encode non-ASCII characters, is now kept as a private copy instead of a borrowed pointer to a window object that may be deallocated. gh-151596: Add missing size positional argument to the pure-Python implementation of io.TextIOBase.readline(). gh-148660: Fix a crash in collections.OrderedDict.copy() when a key’s __eq__ or a subclass method mutates the dict during the copy. Now raises RuntimeError instead, as iteration does. gh-151497: Opening a tarfile archive no longer attempts to pre-allocate a huge buffer when a crafted or truncated member claims an oversized extended header (a GNU long name/link or a pax header). The extended header is now read in bounded chunks, so its size field can no longer trigger memory exhaustion. gh-151403: Fixed a crash in subprocess.Popen (and _posixsubprocess.fork_exec) when an argv item’s __fspath__() concurrently mutates the args sequence being converted. gh-151126: Fix crash on unset MemoryError on allocation failure in ctypes.get_errno(). gh-151416: Fix a crash in os.spawnv() and os.spawnve() when an argv item’s __fspath__() method mutates the argv list during argument conversion. os.spawnv() argument conversion errors other than TypeError, such as the ValueError for an embedded null, are no longer replaced with a generic TypeError. gh-151337: Avoid possible memory leak in tkinter.c on Windows. gh-151126: Fix a crash when MemoryError in os._path_splitroot() was not set properly. gh-119710: Fix asyncio subprocess wait() hanging when the process has exited but one of its pipes is kept open by an inherited child process (so the pipe never reaches EOF). wait() now returns as soon as the process exits, regardless of the pipes’ state. gh-151295: Fixed a crash (use-after-free) in bytes.join() and bytearray.join() that could occur if an item’s __buffer__() concurrently mutates the sequence being joined. The mutation is now reported as a RuntimeError instead. gh-109940: Fix Windows venv activation in cmd.exe to respect VIRTUAL_ENV_DISABLE_PROMPT. gh-117807: Fix mimetypes initialization from MIME map files containing invalid UTF-8 bytes. gh-150771: Fix serialization of email messages using the shift_jis or euc-jp charsets: set_content() now encodes the payload using the output charset, so str(m) no longer raises UnicodeEncodeError. gh-150484: Fix unittest.mock.mock_open() __exit__ raising TypeError when used with contextlib.ExitStack. gh-149319: The asyncio REPL now ignores PYTHONSTARTUP and PYTHON_BASIC_REPL when -E or -I is used. Patch by Jonathan Dung. gh-149221: Catch rare math domain error for random.binomialvariate(). gh-148441: xml.parsers.expat: prevent a crash in CharacterDataHandler() when the character data size exceeds the parser’s buffer size. gh-47005: Fix urllib.request.AbstractHTTPHandler.do_open() to give regular headers set via add_header() priority over unredirected headers, consistent with get_header() and header_items(). gh-123720: asyncio: Fix asyncio.Server.serve_forever() shutdown regression. Since 3.12, cancelling serve_forever() could hang waiting for a handler blocked on a read from a client that never closed (effectively requiring two interrupts to stop); the shutdown sequence now ensures client streams are closed so serve_forever() exits promptly and handlers observe EOF. gh-143988: Fixed crashes in socket.socket.sendmsg() and socket.socket.recvmsg_into() that could occur if buffer sequences are concurrently mutated. gh-130796: Undeprecate the locale.getdefaultlocale() function. Patch by Victor Stinner. gh-115634: Fix a deadlock in concurrent.futures.ProcessPoolExecutor when using max_tasks_per_child, present since the feature was introduced in Python 3.11. The executor stopped scheduling queued tasks after a worker process exited upon reaching its task limit. Based on a fix proposed by Tabrez Mohammed. gh-79638: Disallow all access in urllib.robotparser if the robots.txt file is unreachable due to server or network errors. gh-120665: Fixed an issue where unittest loaders would load and instantiate unittest.TestCase-derived subclasses that are also abstract base classes, which can’t be instantiated. gh-105708: Accept an uppercase V prefix in IPvFuture addresses in urllib.parse.urlsplit(). gh-103925: Fix csv.Sniffer.sniff() for a sample with \r\n line endings in which a quoted field ends a line: a letter could be detected as the delimiter. gh-101267: When a worker process terminates unexpectedly, concurrent.futures.ProcessPoolExecutor now sets a separate BrokenProcessPool exception on each pending future instead of sharing a single instance among them all. Sharing one exception produced malformed tracebacks: each Future.result() call re-raised the same object, appending another copy of the traceback to it. IDLE gh-82183: When the shell is busy running code, using “Run… Customized” with “Restart shell” unchecked now reports that the shell is executing instead of restarting it anyway. gh-83653: Blanking an integer entry in IDLE’s Settings dialog, such as “Auto squeeze min lines”, no longer saves an empty string as an invalid configuration value. gh-65339: Saving the IDLE Shell or an Output window now defaults to a .txt extension and lists text files before Python files, since their content is not Python source. gh-80504: The “In files:” field of IDLE’s Find in Files dialog now always contains a full directory path, even for an unsaved editor or the Shell. This shows in the grep output which directory was searched. gh-134300: Do not add the idlelib directory to the path of the IDLE user process. User code run in IDLE can no longer import idlelib submodules as top-level modules, such as import help. gh-89360: Fix a rare crash in the IDLE editor when the completion window is closed: deleting a key binding for a sequence that is not bound to the virtual event is now ignored instead of raising a ValueError. gh-71956: Fix Replace All in the IDLE editor’s Replace dialog when the search direction is “Up” and “Wrap around” is off: it now replaces all matches above the current position instead of only the first one. gh-152728: Move functions run.fix_scaling, editor.fixwordbreaks (as fix_word_breaks) and pyshell.fix_x11_paste to idlelib.util. gh-66331: Set the WM_CLASS window property of IDLE’s windows to Idle on X11, so that window managers group and label them correctly instead of using the default Toplevel. gh-85320: IDLE now reads and writes its configuration files and the breakpoints file using UTF-8 instead of the locale encoding. This keeps non-ASCII data (such as non-ASCII paths) from being corrupted and makes the files portable between environments. gh-94523: Detect file if modified at local disk and prompt to ask refresh. Patch by Shixian Li. gh-139551: Support rendering BaseExceptionGroup in IDLE. gh-89520: Make IDLE extension configuration look at user config files, allowing user-installed extensions to have settings and key bindings defined in ~/.idlerc. Documentation gh-118150: Clarify in the difflib documentation what junk actually does, its drawbacks, and how to control it. gh-86726: Greatly expand the tkinter documentation to cover the full public API of the package and its submodules. The descriptions are oriented towards Python rather than Tcl/Tk, with corrected return types and versionadded/versionchanged information. Core and Builtins gh-154937: Fix a data race on thread handle identifiers when _thread._shutdown() runs concurrently with the startup of non-daemon threads in the free-threaded build. gh-154709: Fix an out-of-bounds access in reverse dictionary iterators when the underlying dictionary is cleared and modified after the iterator is created. gh-154275: Fix a crash when getting deeply nested __parameters__ from a types.GenericAlias objects. gh-152682: Fix NULL pointer dereference in compile() when a reserved name (e.g. __classdict__) is used as a type parameter name and memory allocation fails while formatting the error message. gh-152635: Fix a crash caused when running out of memory creating a _interpchannels channel. Now a MemoryError is correctly raised. gh-152375: Fix undefined behaviour when a sys.monitoring callback raised an exception while the program was following a branch or loop. gh-152235: Defer GC tracking of set.intersection(), set.difference(), set.symmetric_difference(), set.union() and set.__sub__. Patch by Donghee Na. gh-152235: Defer GC tracking of a set or frozenset to the end of its construction from iterable. Patch by Donghee Na. gh-151905: Fix OOM error handling in PyFrame_GetBack() to propagate exceptions instead of masking them as None. gh-151763: Fix a potential crash in compile(), exec(), eval() and ast.parse() when an allocation fails: the parser or compiler could return without setting an exception. gh-151912: Fixed a crash in type() when selecting a metaclass whose tp_new slot is NULL. Such metaclasses are now rejected with TypeError instead of causing a NULL pointer dereference. gh-151773: Fix a crash in contextvars.ContextVar.set() when memory allocation fails. gh-151126: Fix a crash when sharing memoryview objects between interpreters fails due to running out of memory. It now raises a proper MemoryError. gh-151126: Avoid possible crash in _winapi.c where a device has no memory left. Now it properly raises a MemoryError. Patch by Ivy Xu. gh-151253: If import encodings (first import) fails at Python startup, dump the Python path configuration to help users debugging their configuration. Patch by Victor Stinner. gh-151126: Fix a crash, when there’s no memory left on a device, which happened in _interpchannels module. Now it raises proper MemoryError errors. gh-151065: Fix memory leak when using the mimalloc memory allocator. gh-150988: Fix a reference leak in OSError when attributes are set before super().__init__(). gh-149689: Fix missing error propagation in parser action helpers when memory allocation fails. Patch by Thomas Kowalski. C API gh-152132: Fix Py_RunMain() to return an exit code, rather than calling Py_Exit(), when running a script, a command, or the REPL. Patch by Victor Stinner. Build gh-154070: Build the curses module against a wide-character capable ncurses even when it is not named ncursesw – for example the pkgsrc ncurses on NetBSD and illumos, or the system ncurses on macOS. Such a library previously produced a narrow build. gh-126877: Fix the configure check for Tcl/Tk which could wrongly succeed with optimizing compilers when the libraries are missing. gh-153438: Update Windows build and installer tooling and documentation to use the current download URL for nuget.exe. gh-152502: The curses module now detects set_escdelay(), set_tabsize() and the ESCDELAY and TABSIZE variables with configure capability probes instead of the ncurses-specific NCURSES_EXT_FUNCS macro, so they are exposed when building against other curses implementations such as NetBSD curses that provide them. gh-138800: Fix library name in python3.pc on Android. gh-115869: Make jit_stencils.h (which is produced during JIT builds) reproducible.
python313 py313-html-docs: updated to 3.13.6
Python 3.13.6
macOS
gh-137450: macOS installer shell path management improvements: separate the installer Shell profile updater postinstall script from the Update Shell Profile.command to enable more robust error handling.
gh-137134: Update macOS installer to ship with SQLite version 3.50.4.
Windows
gh-137134: Update Windows installer to ship with SQLite 3.50.4.
Tools/Demos
gh-135968: Stubs for strip are now provided as part of an iOS install.
Tests
gh-135966: The iOS testbed now handles the app_packages folder as a site directory.
gh-135494: Fix regrtest to support excluding tests from --pgo tests. Patch by Victor Stinner.
gh-135489: Show verbose output for failing tests during PGO profiling step with –enable-optimizations.
Security
gh-135661: Fix parsing start and end tags in html.parser.HTMLParser according to the HTML5 standard.
Whitespaces no longer accepted between </ and the tag name. E.g. </ script> does not end the script section.
Vertical tabulation (\v) and non-ASCII whitespaces no longer recognized as whitespaces. The only whitespaces are \t\n\r\f and space.
Null character (U+0000) no longer ends the tag name.
Attributes and slashes after the tag name in end tags are now ignored, instead of terminating after the first > in quoted attribute value. E.g. </script/foo=">"/>.
Multiple slashes and whitespaces between the last attribute and closing > are now ignored in both start and end tags. E.g. <a foo=bar/ //>.
Multiple = between attribute name and value are no longer collapsed. E.g. <a foo==bar> produces attribute “foo” with value “=bar”.
gh-102555: Fix comment parsing in html.parser.HTMLParser according to the HTML5 standard. --!> now ends the comment. -- > no longer ends the comment. Support abnormally ended empty comments <--> and <--->.
gh-135462: Fix quadratic complexity in processing specially crafted input in html.parser.HTMLParser. End-of-file errors are now handled according to the HTML5 specs – comments and declarations are automatically closed, tags are ignored.
gh-118350: Fix support of escapable raw text mode (elements “textarea” and “title”) in html.parser.HTMLParser.
Library
gh-132710: If possible, ensure that uuid.getnode() returns the same result even across different processes. Previously, the result was constant only within the same process. Patch by Bénédikt Tran.
gh-137273: Fix debug assertion failure in locale.setlocale() on Windows.
gh-137257: Bump the version of pip bundled in ensurepip to version 25.2
gh-81325: tarfile.TarFile now accepts a path-like when working on a tar archive. (Contributed by Alexander Enrique Urieles Nieto in gh-81325.)
gh-130522: Fix unraisable TypeError raised during interpreter shutdown in the threading module.
gh-130577: tarfile now validates archives to ensure member offsets are non-negative. (Contributed by Alexander Enrique Urieles Nieto in gh-130577.)
gh-136549: Fix signature of threading.excepthook().
gh-136523: Fix wave.Wave_write emitting an unraisable when open raises.
gh-52876: Add missing keepends (default True) parameter to codecs.StreamReaderWriter.readline() and codecs.StreamReaderWriter.readlines().
gh-85702: If zoneinfo._common.load_tzdata is given a package without a resource a zoneinfo.ZoneInfoNotFoundError is raised rather than a PermissionError. Patch by Victor Stinner.
gh-134759: Fix UnboundLocalError in email.message.Message.get_payload() when the payload to decode is a bytes object. Patch by Kliment Lamonov.
gh-136028: Fix parsing month names containing “İ” (U+0130, LATIN CAPITAL LETTER I WITH DOT ABOVE) in time.strptime(). This affects locales az_AZ, ber_DZ, ber_MA and crh_UA.
gh-135995: In the palmos encoding, make byte 0x9b decode to › (U+203A - SINGLE RIGHT-POINTING ANGLE QUOTATION MARK).
gh-53203: Fix time.strptime() for %c and %x formats on locales byn_ER, wal_ET and lzh_TW, and for %X format on locales ar_SA, bg_BG and lzh_TW.
gh-91555: An earlier change, which was introduced in 3.13.4, has been reverted. It disabled logging for a logger during handling of log messages for that logger. Since the reversion, the behaviour should be as it was before 3.13.4.
gh-135878: Fixes a crash of types.SimpleNamespace on free threading builds, when several threads were calling its __repr__() method at the same time.
gh-135836: Fix IndexError in asyncio.loop.create_connection() that could occur when non-OSError exception is raised during connection and socket’s close() raises OSError.
gh-135836: Fix IndexError in asyncio.loop.create_connection() that could occur when the Happy Eyeballs algorithm resulted in an empty exceptions list during connection attempts.
gh-135855: Raise TypeError instead of SystemError when _interpreters.set___main___attrs() is passed a non-dict object. Patch by Brian Schubert.
gh-135815: netrc: skip security checks if os.getuid() is missing. Patch by Bénédikt Tran.
gh-135640: Address bug where it was possible to call xml.etree.ElementTree.ElementTree.write() on an ElementTree object with an invalid root element. This behavior blanked the file passed to write if it already existed.
gh-135444: Fix asyncio.DatagramTransport.sendto() to account for datagram header size when data cannot be sent.
gh-135497: Fix os.getlogin() failing for longer usernames on BSD-based platforms.
gh-135487: Fix reprlib.Repr.repr_int() when given integers with more than sys.get_int_max_str_digits() digits. Patch by Bénédikt Tran.
gh-135335: multiprocessing: Flush stdout and stderr after preloading modules in the forkserver.
gh-135244: uuid: when the MAC address cannot be determined, the 48-bit node ID is now generated with a cryptographically-secure pseudo-random number generator (CSPRNG) as per RFC 9562, §6.10.3. This affects uuid1().
gh-135069: Fix the “Invalid error handling” exception in encodings.idna.IncrementalDecoder to correctly replace the ‘errors’ parameter.
gh-134698: Fix a crash when calling methods of ssl.SSLContext or ssl.SSLSocket across multiple threads.
gh-132124: On POSIX-compliant systems, multiprocessing.util.get_temp_dir() now ignores TMPDIR (and similar environment variables) if the path length of AF_UNIX socket files exceeds the platform-specific maximum length when using the forkserver start method. Patch by Bénédikt Tran.
gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line SQL statements in the sqlite3 command-line interface.
gh-132969: Prevent the ProcessPoolExecutor executor thread, which remains running when shutdown(wait=False), from attempting to adjust the pool’s worker processes after the object state has already been reset during shutdown. A combination of conditions, including a worker process having terminated abormally, resulted in an exception and a potential hang when the still-running executor thread attempted to replace dead workers within the pool.
gh-130664: Support the '_' digit separator in formatting of the integral part of Decimal’s. Patch by Sergey B Kirpichev.
gh-85702: If zoneinfo._common.load_tzdata is given a package without a resource a ZoneInfoNotFoundError is raised rather than a IsADirectoryError.
gh-130664: Handle corner-case for Fraction’s formatting: treat zero-padding (preceding the width field by a zero ('0') character) as an equivalent to a fill character of '0' with an alignment type of '=', just as in case of float’s.
Documentation
gh-135171: Document that the iterator for the leftmost for clause in the generator expression is created immediately.
Core and Builtins
gh-58124: Fix name of the Python encoding in Unicode errors of the code page codec: use “cp65000” and “cp65001” instead of “CP_UTF7” and “CP_UTF8” which are not valid Python code names. Patch by Victor Stinner.
gh-137314: Fixed a regression where raw f-strings incorrectly interpreted escape sequences in format specifications. Raw f-strings now properly preserve literal backslashes in format specs, matching the behavior from Python 3.11. For example, rf"{obj:\xFF}" now correctly produces '\\xFF' instead of 'ÿ'. Patch by Pablo Galindo.
gh-136541: Fix some issues with the perf trampolines on x86-64 and aarch64. The trampolines were not being generated correctly for some cases, which could lead to the perf integration not working correctly. Patch by Pablo Galindo.
gh-109700: Fix memory error handling in PyDict_SetDefault().
gh-78465: Fix error message for cls.__new__(cls, ...) where cls is not instantiable builtin or extension type (with tp_new set to NULL).
gh-135871: Non-blocking mutex lock attempts now return immediately when the lock is busy instead of briefly spinning in the free threading build.
gh-135607: Fix potential weakref races in an object’s destructor on the free threaded build.
gh-135496: Fix typo in the f-string conversion type error (“exclamanation” -> “exclamation”).
gh-130077: Properly raise custom syntax errors when incorrect syntax containing names that are prefixes of soft keywords is encountered. Patch by Pablo Galindo.
gh-135148: Fixed a bug where f-string debug expressions (using =) would incorrectly strip out parts of strings containing escaped quotes and # characters. Patch by Pablo Galindo.
gh-133136: Limit excess memory usage in the free threading build when a large dictionary or list is resized and accessed by multiple threads.
gh-132617: Fix dict.update() modification check that could incorrectly raise a “dict mutated during update” error when a different dictionary was modified that happens to share the same underlying keys object.
gh-91153: Fix a crash when a bytearray is concurrently mutated during item assignment.
gh-127971: Fix off-by-one read beyond the end of a string in string search.
gh-125723: Fix crash with gi_frame.f_locals when generator frames outlive their generator. Patch by Mikhail Efimov.
Build
gh-135497: Fix the detection of MAXLOGNAME in the configure.ac script.
python313 py313-html-docs: updated to 3.13.3
Python 3.13.3 final
macOS
gh-124111: Update macOS installer to use Tcl/Tk 8.6.16.
gh-131423: Update macOS installer to use OpenSSL 3.0.16. Patch by Bénédikt Tran.
gh-131025: Update macOS installer to ship with SQLite 3.49.1.
gh-91132: Update macOS installer to use ncurses 6.5.
Windows
gh-131423: Update bundled version of OpenSSL to 3.0.16. The new build also disables uplink support, which may be relevant to embedders but has no impact on normal use.
gh-131025: Update Windows installer to ship with SQLite 3.49.1.
gh-131020: pylauncher correctly detects a BOM when searching for the shebang. Fix by Chris Eibl.
Tools/Demos
gh-131852: msgfmt no longer adds the POT-Creation-Date to generated .mo files for consistency with GNU msgfmt.
gh-85012: Correctly reset msgctxt when compiling messages in msgfmt.
gh-130025: The iOS testbed now correctly handles symlinks used as Python framework references.
Tests
gh-131050: test_ssl.test_dh_params is skipped if the underlying TLS library does not support finite-field ephemeral Diffie-Hellman.
gh-129200: Multiple iOS testbed runners can now be started at the same time without introducing an ambiguity over simulator ownership.
gh-130292: The iOS testbed will now run successfully on a machine that has not previously run Xcode tests (such as CI configurations).
gh-130293: The tests of terminal colorization are no longer sensitive to the value of the TERM variable in the testing environment.
gh-126332: Add unit tests for pyrepl.
Security
gh-131809: Update bundled libexpat to 2.7.1
gh-131261: Upgrade to libexpat 2.7.0
gh-127371: Avoid unbounded buffering for tempfile.SpooledTemporaryFile.writelines(). Previously, disk spillover was only checked after the lines iterator had been exhausted. This is now done after each line is written.
gh-121284: Fix bug in the folding of rfc2047 encoded-words when flattening an email message using a modern email policy. Previously when an encoded-word was too long for a line, it would be decoded, split across lines, and re-encoded. But commas and other special characters in the original text could be left unencoded and unquoted. This could theoretically be used to spoof header lines using a carefully constructed encoded-word if the resulting rendered email was transmitted or re-parsed.
Library
gh-132174: Fix function name in error message of _interpreters.run_string.
gh-132171: Fix crash of _interpreters.run_string on string subclasses.
gh-129204: Introduce new _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment variable knob in subprocess to control the use of os.posix_spawn().
gh-132159: Do not shadow user arguments in generated __new__() by decorator warnings.deprecated. Patch by Xuehai Pan.
gh-132075: Fix possible use of socket address structures with uninitialized members. Now all structure members are initialized with zeroes by default.
gh-132002: Fix crash when deallocating contextvars.ContextVar with weird unahashable string names.
gh-131668: socket: Fix code parsing AF_BLUETOOTH socket addresses.
gh-131492: Fix a resource leak when constructing a gzip.GzipFile with a filename fails, for example when passing an invalid compresslevel.
gh-131325: Fix sendfile fallback implementation to drain data after writing to transport in asyncio.
gh-129843: Fix incorrect argument passing in warnings.warn_explicit().
gh-131204: Use monospace font from System Font Stack for cross-platform support in difflib.HtmlDiff.
gh-130940: The PyConfig.use_system_logger attribute, introduced in Python 3.13.2, has been removed. The introduction of this attribute inadvertently introduced an ABI breakage on macOS and iOS. The use of the system logger is now enabled by default on iOS, and disabled by default on macOS.
gh-131045: Fix issue with __contains__, values, and pseudo-members for enum.Flag.
gh-130959: Fix pure-Python implementation of datetime.time.fromisoformat() to reject times with spaces in fractional part (for example, 12:34:56.400 +02:00), matching the C implementation. Patch by Michał Gorny.
gh-130637: Add validation for numeric response data in poplib.POP3.stat() method
gh-130461: Remove .. index:: directives from the uuid module documentation. These directives previously created entries in the general index for getnode() as well as the uuid1(), uuid3(), uuid4(), and uuid5() constructor functions.
gh-130379: The zipapp module now calculates the list of files to be added to the archive before creating the archive. This avoids accidentally including the target when it is being created in the source directory.
gh-130285: Fix corner case for random.sample() allowing the counts parameter to specify an empty population. So now, sample([], 0, counts=[]) and sample('abc', k=0, counts=[0, 0, 0]) both give the same result as sample([], 0).
gh-130250: Fix regression in traceback.print_last().
gh-130230: Fix crash in pow() with only Decimal third argument.
gh-118761: Reverts a change in the previous release attempting to make some stdlib imports used within the subprocess module lazy as this was causing errors during __del__ finalizers calling methods such as terminate, or kill, or send_signal.
gh-130164: Fixed failure to raise TypeError in inspect.Signature.bind() for positional-only arguments provided by keyword when a variadic keyword argument (e.g. **kwargs) is present.
gh-130151: Fix reference leaks in _hashlib.hmac_new() and _hashlib.hmac_digest(). Patch by Bénédikt Tran.
gh-130145: Fix asyncio.AbstractEventloop.run_forever() when another loop is already running.
gh-129726: Fix gzip.GzipFile raising an unraisable exception during garbage collection when referring to a temporary object by breaking the reference loop with weakref.
gh-127750: Remove broken functools.singledispatchmethod() caching introduced in gh-85160.
gh-129583: Update bundled pip to 25.0.1
gh-97850: Update the deprecation warning of importlib.abc.Loader.load_module().
gh-129646: Update the locale alias mapping in the locale module to match the latest X Org locale alias mapping and support new locales in Glibc 2.41.
gh-129603: Fix bugs where sqlite3.Row objects could segfault if their inherited description was set to None. Patch by Erlend Aasland.
gh-128231: Execution of multiple statements in the new REPL now stops immediately upon the first exception encountered. Patch by Bartosz Sławecki.
gh-117779: Fix reading duplicated entries in zipfile by name. Reading duplicated entries (except the last one) by ZipInfo now emits a warning instead of raising an exception.
gh-128772: Fix pydoc for methods with the __module__ attribute equal to None.
gh-92897: Scheduled the deprecation of the check_home argument of sysconfig.is_python_build() to Python 3.15.
gh-128657: Fix possible extra reference when using objects returned by hashlib.sha256() under free threading.
gh-128703: Fix mimetypes.guess_type() to use default mapping for empty Content-Type in registry.
gh-128308: Support the name keyword argument for eager tasks in asyncio.loop.create_task(), asyncio.create_task() and asyncio.TaskGroup.create_task(), by passing on all kwargs to the task factory set by asyncio.loop.set_task_factory().
gh-128388: Fix PyREPL on Windows to support more keybindings, like the Control-← and Control-→ word-skipping keybindings and those with meta (i.e. Alt), e.g. Alt-d to kill-word or Alt-Backspace backward-kill-word.
gh-126037: xml.etree.ElementTree: Fix a crash in Element.find, Element.findtext and Element.findall when the tag to find implements an __eq__() method mutating the element being queried. Patch by Bénédikt Tran.
gh-127712: Fix handling of the secure argument of logging.handlers.SMTPHandler.
gh-126033: xml.etree.ElementTree: Fix a crash in Element.remove when the element is concurrently mutated. Patch by Bénédikt Tran.
gh-118201: Fixed intermittent failures of os.confstr, os.pathconf and os.sysconf on iOS and Android.
gh-124927: Non-printing characters are now properly handled in the new REPL.
IDLE
gh-129873: Simplify displaying the IDLE doc by only copying the text section of idle.html to idlelib/help.html. Patch by Stan Ulbrych.
Documentation
gh-131417: Mention asyncio.Future and asyncio.Task in generic classes list.
gh-125722: Require Sphinx 8.2.0 or later to build the Python documentation. Patch by Adam Turner.
gh-129712: The wheel tags supported by each macOS universal SDK option are now documented.
gh-46236: C API: Document PyUnicode_RSplit(), PyUnicode_Partition() and PyUnicode_RPartition().
Core and Builtins
gh-132011: Fix crash when calling list.append() as an unbound method.
gh-131998: Fix a crash when using an unbound method descriptor object in a function where a bound method descriptor was used.
gh-131988: Fix a performance regression that caused scaling bottlenecks in the free threaded build in 3.13.1 and 3.13.2.
gh-131719: Fix missing NULL check in _PyMem_FreeDelayed in free-threaded build.
gh-131670: Fix anext() failing on sync __anext__() raising an exception.
gh-131141: Fix data race in sys.monitoring instrumentation while registering callback.
gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing
gh-130851: Fix a crash in the free threading build when constructing a code object with co_consts that contains instances of types that are not otherwise generated by the bytecode compiler.
gh-130794: Fix memory leak in the free threaded build when resizing a shared list or dictionary from multiple short-lived threads.
gh-130775: Do not crash on negative column and end_column in ast locations.
gh-130382: Fix PyRefTracer_DESTROY not being sent from Python/ceval.c Py_DECREF().
gh-130618: Fix a bug that was causing UnicodeDecodeError or SystemError to be raised when using f-strings with lambda expressions with non-ASCII characters. Patch by Pablo Galindo
gh-130163: Fix possible crashes related to concurrent change and use of the sys module attributes.
gh-88887: Fixing multiprocessing Resource Tracker process leaking, usually observed when running Python as PID 1.
gh-130115: Fix an issue with thread identifiers being sign-extended on some platforms.
gh-128396: Fix a crash that occurs when calling locals() inside an inline comprehension that uses the same local variable as the outer frame scope where the variable is a free or cell var.
gh-116042: Fix location for SyntaxErrors of invalid escapes in the tokenizer. Patch by Pablo Galindo
gh-129983: Fix data race in compile_template in sre.c.
gh-129967: Fix a race condition in the free threading build when repr(set) is called concurrently with set.clear().
gh-129900: Fix return codes inside SystemExit not getting returned by the REPL.
gh-129732: Fixed a race in _Py_qsbr_reserve in the free threading build.
gh-129643: Fix thread safety of PyList_Insert() in free-threading builds.
gh-129668: Fix race condition when raising MemoryError in the free threaded build.
gh-129643: Fix thread safety of PyList_SetItem() in free-threading builds. Patch by Kumar Aditya.
gh-128714: Fix the potential races in get/set dunder methods __annotations__, __annotate__ and __type_params__ for function object, and add related tests.
gh-128632: Disallow __classdict__ as the name of a type parameter. Using this name would previously crash the interpreter in some circumstances.
gh-127953: The time to handle a LINE event in sys.monitoring (and sys.settrace) is now independent of the number of lines in the code object.
gh-125331: from __future__ import barry_as_FLUFL now works in more contexts, including when it is used in files, with the -c flag, and in the REPL when there are multiple statements on the same line. Previously, it worked only on subsequent lines in the REPL, and when the appropriate flags were passed directly to compile(). Patch by Pablo Galindo.
C API
gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen.
gh-129533: Update PyGC_Enable(), PyGC_Disable(), PyGC_IsEnabled() to use atomic operation for thread-safety at free-threading build. Patch by Donghee Na.
Build
gh-131865: The DTrace build now properly passes the CC and CFLAGS variables to the dtrace command when utilizing SystemTap on Linux.
gh-131675: Fix mimalloc library builds for 32-bit ARM targets.
gh-130673: Fix potential KeyError when handling object sections during JIT building process.
gh-130740: Ensure that Python.h is included before stdbool.h unless pyconfig.h is included before or in some platform-specific contexts.
gh-129838: Don’t redefine _Py_NO_SANITIZE_UNDEFINED when compiling with a recent GCC version and undefined sanitizer enabled.
gh-129660: Drop test_embed from PGO training, whose contribution in recent versions is considered to be ignorable.
python313 py313-html-docs: added version 3.13.0 Python 3.13 is the latest stable release of the Python programming language, with a mix of changes to the language, the implementation and the standard library. The biggest changes include a new interactive interpreter, experimental support for running in a free-threaded mode (PEP 703), and a Just-In-Time compiler (PEP 744). Error messages continue to improve, with tracebacks now highlighted in color by default. The locals() builtin now has defined semantics for changing the returned mapping, and type parameters now support default values. The library changes contain removal of deprecated APIs and modules, as well as the usual improvements in user-friendliness and correctness. Several legacy standard library modules have now been removed following their deprecation in Python 3.11 (PEP 594).