Update `test_io` `_check_warn_on_dealloc` to use `self.` to dispatch to
different I/O implementations.
Update the `_pyio` implementation to match expected behavior, using the
same `_dealloc_warn` design as the C implementation uses to report the
topmost `__del__` object.
The FileIO one now matches all the others, so can use IOBase. There was
a missing check on closing (self._fd must be valid), add that check
(cherry picked from commit 5b0e827521)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Test was only testing _io, expanded to cover _pyio.
(cherry picked from commit 06eaf4055c)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
It now supports a "full" fallback to _PyFunction_GetXIData() and then `_PyPickle_GetXIData()`.
There's also room for other fallback modes if that later makes sense.
(cherry picked from commit 88f8102a8f, AKA gh-133482)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Two special methods, __buffer__ and __release_buffer__ were added to
Python 3.12 by PEP 688. The C API Type Object documentation for slots
includes `tp_as_buffer`, and sub-slots `bf_getbuffer`, `bf_releasebuffer`
but does not refer to the Python Data Model version of those. Add the
missing references.
(cherry picked from commit b529b60fc2)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
gh-132983: Add documentation for compression.zstd (GH-133911)
Add documentation for compression & compression.zstd.
🎉
---------
(cherry picked from commit d862b6de1b)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Sumana Harihareswara <sh@changeset.nyc>
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
Fix signature of `_curses.assume_default_colors` in the docs (GH-134409)
(cherry picked from commit dcfc91e4e5)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-133980: use atomic store in `PyObject_GenericSetDict` (GH-133988)
(cherry picked from commit ec39fd2c20)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-72680: Fix false positives when using zipfile.is_zipfile() (GH-134250)
bpo-28494: Improve zipfile.is_zipfile reliability
The zipfile.is_zipfile function would only search for the EndOfZipfile
section header. This failed to correctly identify non-zipfiles that
contained this header. Now the zipfile.is_zipfile function verifies
the first central directory entry.
Changes:
* Extended zipfile.is_zipfile to verify zipfile catalog
* Added tests to validate failure of binary non-zipfiles
* Reuse 'concat' handling for is_zipfile
(cherry picked from commit 1298511b41)
Co-authored-by: Tim Hatch <timhatch@netflix.com>
Co-authored-by: John Jolly <john.jolly@gmail.com>
(cherry picked from commit a3a3cf6d15)
Co-authored-by: Kevin Hernández <kevin.hernandez@unet.edu.ve>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
gh-134209: use heap-allocated memory in `_curses.window.{instr,getstr}` (GH-134283)
* made curses buffer heap allocated instead of stack
* change docs to explicitly mention the max buffer size
* changing GetStr() function to behave similarly too
* Update Doc/library/curses.rst
* Update instr with proper return error handling
* Update Modules/_cursesmodule.c
* change to strlen and better memory safety
* change from const int to Py_ssize_t
* add mem allocation guard
* update versionchanged to mention it was an increase.
* explicitly use versionchanged 3.14 as that is its own branch now.
TESTED: `python -m test -u curses test_curses`
---------
(cherry picked from commit aadda87b3d)
Co-authored-by: tigerding <43339228+zydtiger@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-85045: clarified that the underlying buffer of a TextIOBase can be a RawIOBase (GH-134372)
Added a clarification that the underlying binary buffer of a TextIOBase can be a BufferedIOBase OR a RawIOBase
(cherry picked from commit 36eb711d2f)
Co-authored-by: Alex Kautz <alex@takemobi.com>
Adds some additional test xfails for Emscripten stack overflows. Also corrects a test skip for test_io.
(cherry picked from commit 91e6a58e2d)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Using the if instruction results in slightly shorter trampoline code.
(cherry picked from commit 3b7888bf3d)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962)
* Add "cyclic isolate" to the glossary.
* Add a new "Object Life Cycle" page.
* Improve docs for related API, with special focus on cross-references and warnings
(cherry picked from commit 3246ea514d)
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
gh-127945: Update What's New in Python 3.14 for free-threaded ctypes (GH-134332)
(cherry picked from commit b430e92dd8)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx (GH-134238)
(cherry picked from commit 317c496223)
Co-authored-by: Donghee Na <donghee.na@python.org>
gh-128307: Update what's new in 3.13 and 3.14 with create_task changes of asyncio (GH-134304)
(cherry picked from commit 28625d4f95)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gh-53189: Document peculiarities of InteractiveConsole in relation to pickle (GH-123069)
(cherry picked from commit a31bbc951a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
UnicodeEncodeError is now handled the same way as OSError during
TarFile member extraction.
(cherry picked from commit 9983c7d441)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-133940: test_strftime incorrectly calculates expected week (GH-134281)
Let the system determine the correct tm_wday and tm_isdst.
(cherry picked from commit e3dda8f818)
Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
gh-131505: Move len boundary assertions before using len. (GH-131536)
Move len boundary assertions before using len.
(cherry picked from commit c45e661226)
Co-authored-by: naya451 <41294408+naya451@users.noreply.github.com>
* Ensure that created files and dirs are always removed after test.
Now addCleanup() does not conflict with tearDown().
* Use os_helper.unlink() and os_helper.rmdir().
* Import TESTFN from os_helper.
(cherry picked from commit e29171bf8a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-132983: Call Py_XDECREF rather than PyObject_GC_Del in failed __new__ (GH-133962)
Call Py_XDECREF rather than PyObject_GC_Del in failed __new__
This will call tp_dealloc and clear all members.
(cherry picked from commit e575190abb)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-134201: Expand explanation of Base85 encodings in base64 docs (GH-134288)
Explain history of de-facto standard and how to pick between the two Base-85 encoding functions in the base-64 module.
---------
(cherry picked from commit 66aaad6103)
Co-authored-by: Alek Binion <aleksander.binion@gmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
gh-134235: Import Autocomplete for Builtin Modules (GH-134277)
* added enhancement auto completing import with sys builtins
---------
(cherry picked from commit 8421b03b16)
Co-authored-by: Tom Wang <85062819+tommix626@users.noreply.github.com>
Co-authored-by: Hunter <hyoung3@gmail.com>
Extension builders must specify Py_GIL_DISABLED if they want to link to the free-threaded builds.
This was usually the case already, but this change guarantees it in all circumstances.
The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.
Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.
(cherry picked from commit b22460c44d)
Co-authored-by: Étienne Pelletier <EtiennePelletier@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>