summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* gh-101196: Make isdir/isfile/exists faster on Windows (GH-101324)Michael Droettboom2023-02-082-1/+563
| | | Co-authored-by: Eryk Sun <eryksun@gmail.com>
* GH-101578: Normalize the current exception (GH-101607)Mark Shannon2023-02-083-12/+54
| | | | | | | | | | * Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
* gh-101656: Fix "conversion from Py_ssize_t to int" warning in ↵Nikita Sobolev2023-02-071-3/+3
| | | | `_testcapimodule` (#101657)
* gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ ↵Matthieu Dartiailh2023-02-071-1/+140
| | | | | (#101127) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-99108: Replace SHA2-224 & 256 with verified code from HACL* (#99109)Jonathan Protzenko2023-02-0711-346/+1753
| | | | | | | | | | | | | | | | | | | | | | replacing hashlib primitives (for the non-OpenSSL case) with verified implementations from HACL*. This is the first PR in the series, and focuses specifically on SHA2-256 and SHA2-224. This PR imports Hacl_Streaming_SHA2 into the Python tree. This is the HACL* implementation of SHA2, which combines a core implementation of SHA2 along with a layer of buffer management that allows updating the digest with any number of bytes. This supersedes the previous implementation in the tree. @franziskuskiefer was kind enough to benchmark the changes: in addition to being verified (thus providing significant safety and security improvements), this implementation also provides a sizeable performance boost! ``` --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- Sha2_256_Streaming 3163 ns 3160 ns 219353 // this PR LibTomCrypt_Sha2_256 5057 ns 5056 ns 136234 // library used by Python currently ``` The changes in this PR are as follows: - import the subset of HACL* that covers SHA2-256/224 into `Modules/_hacl` - rewire sha256module.c to use the HACL* implementation Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-59956: Add a Test to Verify GILState Matches the "Current" Thread State ↵Eric Snow2023-02-061-0/+37
| | | | | | | (gh-101625) This test should have been in gh-101431. https://github.com/python/cpython/issues/59956
* gh-101609: Fix "‘state’ may be used uninitialized" warning in ↵Nikita Sobolev2023-02-061-2/+3
| | | | | | | `_xxinterpchannelsmodule` (GH-101610) I went with the easiest solution: just removing the offending line. See the issue description with my reasoning. https://github.com/python/cpython/issues/101609
* gh-101543: Ensure Windows registry path is only used when stdlib can't be ↵Steve Dower2023-02-061-19/+12
| | | | found (GH-101544)
* gh-76961: Fix buildbot failures in test_pep3118 (#101587)Mark Dickinson2023-02-061-3/+3
| | | This PR fixes the buildbot failures introduced by the merge of #5561, by restricting the relevant tests to something that should work on both 32-bit and 64-bit platforms. It also silences some compiler warnings introduced in that PR.
* gh-101372: Fix unicodedata.is_normalized to properly handle the UCD 3… ↵Dong-hee Na2023-02-061-1/+1
| | | | (gh-101388)
* gh-76961: Fix the PEP3118 format string for ctypes.Structure (#5561)Eric Wieser2023-02-051-30/+87
| | | | | | | | | | | | | | | | | | | | The summary of this diff is that it: * adds a `_ctypes_alloc_format_padding` function to append strings like `37x` to a format string to indicate 37 padding bytes * removes the branches that amount to "give up on producing a valid format string if the struct is packed" * combines the resulting adjacent `if (isStruct) {`s now that neither is `if (isStruct && !isPacked) {` * invokes `_ctypes_alloc_format_padding` to add padding between structure fields, and after the last structure field. The computation used for the total size is unchanged from ctypes already used. This patch does not affect any existing aligment computation; all it does is use subtraction to deduce the amount of paddnig introduced by the existing code. --- Without this fix, it would never include padding bytes - an assumption that was only valid in the case when `_pack_` was set - and this case was explicitly not implemented. This should allow conversion from ctypes structs to numpy structs Fixes https://github.com/numpy/numpy/issues/10528
* Revert "gh-89381: Fix invalid signatures of math/cmath.log (#101404)" (#101580)Mark Dickinson2023-02-054-35/+41
| | | This reverts commit 0ef92d979311ba82d4c41b22ef38e12e1b08b13d.
* GH-100485: Create an alternative code path when an accurate fma() ↵Raymond Hettinger2023-02-041-0/+43
| | | | implementation is not available (#101567)
* gh-101322: Ensure test_zlib.ZlibDecompressorTest runs, fix errors in ↵Ruben Vorderman2023-02-041-0/+1
| | | | | ZlibDecompressor (#101323) * Ensure test_zlib.ZlibDecompressorTest actually runs, fix errors in ZlibDecompressor.
* gh-101524: Split Up the _xxsubinterpreters Module (gh-101526)Eric Snow2023-02-045-2178/+2392
| | | | | This is step 1 in potentially dropping all the "channel"-related code. Channels have already been removed from PEP 554. https://github.com/python/cpython/issues/101524
* gh-101277: Port more `itertools` static types to heap types (#101303)Erlend E. Aasland2023-02-032-328/+202
| | | Add dropwhile, takewhile, starmap, combinations*, and permutations types to module state.
* gh-101277: Isolate itertools, add group and _grouper types to module state ↵Erlend E. Aasland2023-02-012-111/+141
| | | | | (#101302) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-101409: Improve generated clinic code for self type checks (#101411)Erlend E. Aasland2023-01-318-48/+47
|
* gh-101469: Optimise get_io_state() by using _PyModule_GetState() (GH-101470)Erlend E. Aasland2023-01-311-1/+2
| | | Automerge-Triggered-By: GH:erlend-aasland
* gh-59956: Clarify Runtime State Status Expectations (gh-101308)Eric Snow2023-01-301-1/+1
| | | | | | | | | | | | | A PyThreadState can be in one of many states in its lifecycle, represented by some status value. Those statuses haven't been particularly clear, so we're addressing that here. Specifically: * made the distinct lifecycle statuses clear on PyThreadState * identified expectations of how various lifecycle-related functions relate to status * noted the various places where those expectations don't match the actual behavior At some point we'll need to address the mismatches. (This change also includes some cleanup.) https://github.com/python/cpython/issues/59956
* GH-101291: Refactor the `PyLongObject` struct into object header and ↵Mark Shannon2023-01-301-5/+5
| | | | PyLongValue struct. (GH-101292)
* gh-89381: Fix invalid signatures of math/cmath.log (#101404)Sergey B Kirpichev2023-01-294-41/+35
|
* GH-100485: Add extended accuracy test. Switch to faster fma() based ↵Raymond Hettinger2023-01-281-36/+17
| | | | variant. GH-101383)
* gh-77532: Minor tweaks to allow compiling with PlatformToolset=ClangCL on ↵Steve Dower2023-01-271-0/+6
| | | | | | Windows (GH-101352) To use this, ensure that clang support was selected in Visual Studio Installer, then set the PlatformToolset environment variable to "ClangCL" and build as normal from the command line. It remains unsupported, but at least is possible now for experimentation.
* Speed-up and improve accuracy with Rump Algorithms (3.1) and (5.10) (GH-101366)Raymond Hettinger2023-01-271-21/+16
|
* gh-99952: [ctypes] fix refcount issues in from_param() result. (#100169)Yukihiro Nakadaira2023-01-262-0/+9
| | | | | Fixes a reference counting issue with `ctypes.Structure` when a `from_param()` method call is used and the structure size is larger than a C pointer `sizeof(void*)`. This problem existed for a very long time, but became more apparent in 3.8+ by change likely due to garbage collection cleanup timing changes.
* gh-94518: Rename `group*` to `extra_group*` to avoid confusion (#101054)Oleg Iarygin2023-01-261-28/+28
| | | | | * Rename `group*` to `extra_group*` to avoid confusion * Rename `num_groups` into `extra_group_size` * Rename `groups_list` to `extra_groups_packed`
* gh-101326: Fix regression when passing None to FutureIter.throw (#101327)Shantanu2023-01-251-1/+6
|
* gh-92123: Adapt _elementtree to multi-phase init (PEP 489) (#101285)Erlend E. Aasland2023-01-242-130/+278
|
* GH-92123: Pass _elementtree state as parameter (#101189)Erlend E. Aasland2023-01-241-57/+73
|
* gh-101152: Implement PEP 699 (GH-101193)ram vikram singh2023-01-241-0/+3
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Ken Jin <kenjin@python.org>
* gh-100795: Don't call freeaddrinfo on failure. (#101252)Gregory P. Smith2023-01-231-0/+4
| | | | | | | | | When getaddrinfo returns an error, the output pointer is in an unknown state Don't call freeaddrinfo on it. See the issue for discussion and details with links to reasoning. _Most_ libc getaddrinfo implementations never modify the output pointer unless they are returning success. Co-authored-by: Sergey G. Brester <github@sebres.de> Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* GH-92123: Store _elementtree state in type contexts (#101190)Erlend E. Aasland2023-01-231-17/+21
| | | | - add state pointer to TreeBuilderObject - add state pointer to XMLParserObject
* gh-83122: Deprecate testing element truth values in `ElementTree` (#31149)Jacob Walls2023-01-231-0/+18
| | | | | | | When testing element truth values, emit a DeprecationWarning in all implementations. This had emitted a FutureWarning in the rarely used python-only implementation since ~2.7 and has always been documented as a behavior not to rely on. Matching an element in a tree search but having it test False can be unexpected. Raising the warning enables making the choice to finally raise an exception for this ambiguous behavior in the future.
* Sumprod(): Update citation. Reorder functions. Add final twosum() call. ↵Raymond Hettinger2023-01-221-38/+21
| | | | Improve comments. (#101249)
* Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed ↵Kumar Aditya2023-01-221-2/+0
| | | | | | | `getaddrinfo` (#101220)" (#101238) Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)" This reverts commit 5f08fe4a2c055880c23c6f9b57ff03005d193bfc.
* gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)Sergey G. Brester2023-01-221-0/+2
| | | Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* gh-99266: ctypes: Preserve more detailed exception in `ArgumentError`Kamil Turek2023-01-211-3/+17
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* GH-92123: Move _elementtree heap types to module state (#101187)Erlend E. Aasland2023-01-212-64/+98
|
* gh-92123: Convert `_elementtree` types to heap types (#99221)Erlend E. Aasland2023-01-202-236/+164
|
* GH-90699: Clear interned strings in `_elementtree` (#101185)Erlend E. Aasland2023-01-201-0/+10
|
* gh-59956: Clarify GILState-related Code (gh-101161)Eric Snow2023-01-192-13/+2
| | | | | | | | | | The objective of this change is to help make the GILState-related code easier to understand. This mostly involves moving code around and some semantically equivalent refactors. However, there are a also a small number of slight changes in structure and behavior: * tstate_current is moved out of _PyRuntimeState.gilstate * autoTSSkey is moved out of _PyRuntimeState.gilstate * autoTSSkey is initialized earlier * autoTSSkey is re-initialized (after fork) earlier https://github.com/python/cpython/issues/59956
* gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)Paul Moore2023-01-171-1/+16
| | | Don't send partial UTF-8 sequences to the Windows API
* gh-100320: Fix path calculations on Windows when python.exe is moved outside ↵Steve Dower2023-01-161-18/+30
| | | | of the normal location (GH-100947)
* GH-100997: fix refleak in `_testinternalcapi.c` (#101058)Kumar Aditya2023-01-161-0/+1
|
* Fix `ctypes` typo in `set_exception` (#101040)Cristián Maureira-Fredes2023-01-151-1/+1
|
* GH-100892: consolidate `HEAD_LOCK/HEAD_UNLOCK` macros (#100953)Kumar Aditya2023-01-151-5/+0
|
* gh-94518: [_posixsubprocess] Replace variable validity flags with reserved ↵Oleg Iarygin2023-01-141-33/+30
| | | | | | | | | | | | | values (#94687) Have _posixsubprocess.c stop using boolean flags to say if gid and uid values were supplied and action is required. Such an implicit "either initialized or look somewhere else" confused both the reader (another mental connection to constantly track between functions) and a compiler (warnings on potentially uninitialized variables being passed). Instead, we can utilize a special group/user id as a flag value -1 defined by POSIX but used nowhere else. Namely: gid: call_setgid = False → gid = -1 uid: call_setuid = False → uid = -1 groups: call_setgroups = False → groups = NULL (obtained with (groups_list != Py_None) ? groups : NULL) This PR is required for #94519.
* GH-100997: Implement Multi-Phase Init for the _testinternalcapi Module ↵Eric Snow2023-01-121-30/+117
| | | | | | | (gh-100998) _testinternalcapi is an internal module used for testing. https://github.com/python/cpython/issues/100997
* GH-100892: Fix race in clearing `threading.local` (#100922)Kumar Aditya2023-01-112-15/+56
|