Followup to 942673ed19 (GH-133588)
* Update configure for Python 3.15
* Update magic number for 3.15
* Remove deprecated 'check_home' argument from sysconfig.is_python_build
* Add warningignore entries for Modules/_sqlite/clinic/connection.c.h
* Work around c-analyzer complaints about _testclinic deprecation tests
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Py_HAVE_C_COMPLEX was added in 3.14 so the removal doesn't need a deprecation
period even under a strict reading of PEP 387.
The Py_FFI_SUPPORT_C_COMPLEX check configure check implies support for
complex types in ctypes.
* Add _zstd module for https://peps.python.org/pep-0784/
This commit introduces the `_zstd` module, with bindings to libzstd from
the pyzstd project. It also includes the unix build system configuration.
Windows build system support will be integrated independently as it
depends on integration with cpython-source-deps.
* Add _zstd to modules
* Fix path for compression.zstd module
* Ignore _zstd module like _io
* Expand module state macros to improve code quality
Also removes module state references from the classes in the _zstd
module and instead uses PyType_GetModuleState()
* Remove backticks suggested in review
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
* Use critical sections to lock object state
This should avoid races and deadlocks.
* Remove compress/decompress and mark module as not reliant on the GIL
The `compress`/`decompress` functions will be moved to Python code for simplicity.
C implementations can always be re-added in the future.
Also, mark _zstd as not requiring the GIL.
* Lift critical section to avoid clang warning
* Respond to comments by picnixz
* Call out pyzstd explicitly in license description
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* Use a much more robust implementation...
... for `get_zstd_state_from_type`
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Use PyList_GetItemRef for thread safety purposes
* Use a macro for the minimum supported version
* remove const from primivite types
* Use PyMem_New in another spot
* Simplify error handling in _get_frame_size
* Another simplification of error handling in get_frame_info
* Rename _module_state to mod_state
* Rewrite comment explaining the context of the code
* Add link to pyzstd
* Add TODO about refactoring dict training code
* Use PyModule_AddObjectRef over PyModule_AddObject
PyModule_AddObject is soft-deprecated, so we should use PyModule_AddObjectRef
* Check result of OutputBufferGrow
* Simplify return logic in `add_constant_to_type`
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Ignore return value of _zstd_clear()
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Remove redundant comments
* Remove __reduce__ from ZstdDict
We should instead document that to pickle a dictionary a user should use
the `.dict_content` attribute.
* Use PyUnicode_FromFormat instead of a buffer
* Don't use C constants/types in error messages
* Make error messages easier to understand for Python users
* Lower minimum required version 1.4.0
* Use casts and make slot function signatures correct
* Be consistent with CPython on const usage
* Make else clauses in line with PEP 7
* Fix over-indented blocks in argument clinic
* Add critical section around ZSTD_DCtx_setParameter
* Add a TODO about refactoring critical sections
* Use Py_UNREACHABLE
* Move bytes operations out of Py_BEGIN_ALLOW_THREADS
* Add TODO about ensuring a lock is held
* Remove asserts that may not be correct
* Add TODO to make ZstdDict and others GC objects
* Make objects GC tracked
* Remove unused include
* Fix some memory issues
* Fix refleaks on module and in ZstdDict
* Update configure to check for ZDICT_finalizeDictionary
* Properly check version in configure
* exit(1) if check fails
* Use AC_RUN_IFELSE
* Use a define() to re-use version check
* Actually properly set _zstd module status based on version
---------
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* simplify HACL* build for MD5, SHA1, SHA2 and SHA3 modules
* remove statically linked libraries for HACL* implementation
* is it better now?
* is it better now?
* fixup
* Present HACL* as a static or shared library.
On WASI, extension modules based on HACL* require the HACL*
library to be linked statically. On other platforms, it can
be built dynamically.
* amend whitespace
* remove temporary .so file as it requires more symlinks
* avoid smelly symbols
* fixup checksums
* regen sbom
* fixup shell warnings and comments
* it *should* work
Change the default LTO flags on GCC to not pass -flto-partition=none, and allow parallelization of LTO. This has a multiple factor speedup for LTO build times on GCC, with no noticeable loss in performance.
On newer make and newer GCC, this passes the jobserver automatically to GCC (or more like GCC grabs it from the env vars).
On older make, this will have benign warnings about serial compilation. It's safe to ignore them.
Make `warnings.catch_warnings()` use a context variable for holding
the warning filtering state if the `sys.flags.context_aware_warnings`
flag is set to true. This makes using the context manager thread-safe in
multi-threaded programs.
Add the `sys.flags.thread_inherit_context` flag. If true, starting a new
thread with `threading.Thread` will use a copy of the context
from the caller of `Thread.start()`.
Both these flags are set to true by default for the free-threaded build
and false for the default build.
Move the Python implementation of warnings.py into _py_warnings.py.
Make _contextvars a builtin module.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.
The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMAC
is not available or disabled. For now, only named hash algorithms are recognized and SIMD support provided
by HACL* for the BLAKE2 hash functions is not yet used.
Modifies the behavior of the interpreter on crash under Emscripten:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown
The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows
* Remove calls to PyOS_CheckStack
* Add stack protection to parser
* Make tests more robust to low stacks
* Improve error messages for stack overflow
Replace AC_CACHE_VAL/AC_CHECK_HEADER with a cleaner variant using
AC_CACHE_CHECK/AC_PREPROC_IFELSE.
The former would produce garbled output when config.cache was reused. It
also required directly manipulating GNU Autoconf cache variables.
`emcc -dumpversion` will sometimes say e.g., `4.0.0-git` but in this case
uname does not include `-git` in the version string. Use cut to delete
everything after the dash.