Commit Graph

27266 Commits

Author SHA1 Message Date
Kumar Aditya 1a84cc007e
GH-102397: Fix segfault from race condition in signal handling (#102399)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-03-08 13:29:39 +05:30
Thomas Wouters f9774e57d8 Python 3.12.0a6 2023-03-07 22:48:18 +01:00
Irit Katriel a33ca2ad1f
gh-102493: fix normalization in PyErr_SetObject (#102502)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-03-07 13:27:46 -08:00
Pablo Galindo Salgado f533f216e6
gh-102416: Do not memoize incorrectly loop rules in the parser (#102467) 2023-03-06 14:41:53 +01:00
Barney Gale 6716254e71
GH-101362: Optimise PurePath(PurePath(...)) (GH-101667)
The previous `_parse_args()` method pulled the `_parts` out of any supplied `PurePath` objects; these were subsequently joined in `_from_parts()` using `os.path.join()`. This is actually a slower form of joining than calling `fspath()` on the path object, because it doesn't take advantage of the fact that the contents of `_parts` is normalized!

This reduces the time taken to run `PurePath("foo", "bar")` by ~20%, and the time taken to run `PurePath(p, "cheese")`, where `p = PurePath("/foo", "bar", "baz")`, by ~40%.

Automerge-Triggered-By: GH:AlexWaygood
2023-03-05 15:50:21 -08:00
Barney Gale 3e60e0213e
GH-101362: Check pathlib.Path flavour compatibility at import time (GH-101664)
This saves a comparison in `pathlib.Path.__new__()` and reduces the time taken to run `Path()` by ~5%.

Automerge-Triggered-By: GH:AlexWaygood
2023-03-05 14:46:45 -08:00
Barney Gale 3572c861d8
GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (#101665)
GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath

This reduces the time taken to run `PurePath("foo")` by ~15%
2023-03-05 22:00:56 +00:00
Yeojin Kim 9a478be1a4
gh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (#102318) 2023-03-05 06:54:33 -08:00
Marta Gómez Macías 66aa78cbe6
gh-102356: Add thrashcan macros to filter object dealloc (#102426)
Add thrashcan macros to the deallocator of the filter objects to protect against deeply nested destruction of chains of nested filters.
2023-03-05 12:00:41 +01:00
Matthias Görgens eff9f43924
gh-96821: Add config option `--with-strict-overflow` (#96823)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Shantanu <hauntsaninja@gmail.com>
2023-03-04 13:39:52 -08:00
Jaysinh Shukla 81763341ed
gh-63301: Set exit code when tabnanny CLI exits on error (#7699)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-03-04 13:32:13 -08:00
Byeongmin Choi 77a3196b7c
gh-101863: Fix wrong comments in EUC-KR codec (gh-102417) 2023-03-05 01:01:54 +09:00
Gouvernathor 90801e48fd
gh-102302 Micro-optimize `inspect.Parameter.__hash__` (#102303) 2023-03-04 15:08:57 +00:00
Alexey Izbyshev c2bd55d26f
gh-102179: Fix `os.dup2` error reporting for negative fds (#102180) 2023-03-04 19:54:08 +05:30
Raj 705487c655
gh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (#101896)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-03-04 19:51:29 +05:30
Max Bachmann c1748ed59d
gh-102344: Reimplement winreg QueryValue / SetValue using QueryValueEx / SetValueEx (GH-102345)
The newer APIs are more widely available than the old ones, and are called in a way to preserve functionality.
2023-03-01 14:50:38 +00:00
Max Bachmann 938e36f824
gh-102336: Remove code specifically for handling Windows 7 (GH-102337) 2023-03-01 00:31:21 +00:00
Petr Viktorin 6b2d7c0ddb
gh-101101: Unstable C API tier (PEP 689) (GH-101102) 2023-02-28 09:31:01 +01:00
Steven Troxler 0f89acf6cc
gh-101561: Add typing.override decorator (#101564)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-02-27 13:16:11 -08:00
Sergey B Kirpichev 4f3786b761
gh-101773: Optimize creation of Fractions in private methods (#101780)
This PR adds a private `Fraction._from_coprime_ints` classmethod for internal creations of `Fraction` objects, replacing the use of `_normalize=False` in the existing constructor. This speeds up creation of `Fraction` objects arising from calculations. The `_normalize` argument to the `Fraction` constructor has been removed.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-02-27 18:53:22 +00:00
Dennis Sweeney e3c3f9fec0
gh-102250: Fix double-decref in COMPARE_AND_BRANCH error case (GH-102287) 2023-02-27 10:46:40 +00:00
Rotzbua f3cb15c88a
gh-91038: Change default argument value to `False` instead of `0` (#31621)
The argument is used as a switch and corresponds to a boolean logic. Therefore it is more intuitive to use the corresponding constant `False` as default value instead of the integer `0`.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-02-26 18:10:34 -08:00
Pradyun Gedam 89d9ff0f48
gh-101997: Update bundled pip version to 23.0.1 (#101998) 2023-02-25 12:00:12 +00:00
Kumar Aditya 5f11478ce7
GH-102126: fix deadlock at shutdown when clearing thread states (#102222) 2023-02-25 12:21:36 +05:30
SKO 56e93c8020
gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207)
Co-authored-by: Seonkyo Ok <seonkyo.ok@linecorp.com>
2023-02-25 11:26:40 +09:00
Ionite 54dfa14c5a
gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` when internal access of `builtins.__dict__` exhausts the iterator (#101769) 2023-02-24 15:02:04 -08:00
Max Bachmann 1fa38906f0
gh-102141: replace use of getpid on Windows with GetCurrentProcessId (GH-102142) 2023-02-24 12:38:21 +00:00
Yeojin Kim 347f7406df
gh-81652: Add MAP_ALIGNED_SUPER FreeBSD and MAP_CONCEAL OpenBSD constants (gh-102191) 2023-02-24 19:26:51 +09:00
Jacob Bower 0c857865e4
Fix deadlock on shutdown if test_current_{exception,frames} fails (#102019)
* Don't deadlock on shutdown if test_current_{exception,frames} fails

These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads.

Co-authored-by: Brett Simmers <bsimmers@meta.com>

* Add a news entry

* Fix whitespace

---------

Co-authored-by: Brett Simmers <bsimmers@meta.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-02-23 14:57:06 -08:00
Zackery Spytz 665730d217
bpo-23224: Fix segfaults and multiple leaks in the lzma and bz2 modules (GH-7822)
lzma.LZMADecompressor and bz2.BZ2Decompressor objects caused
segfaults when their `__init__()` methods were not called.

lzma.LZMADecompressor, lzma.LZMACompressor, bz2.BZ2Compressor,
and bz2.BZ2Decompressor objects would leak locks and internal buffers
when their `__init__()` methods were called multiple times.


https://bugs.python.org/issue23224
2023-02-23 06:00:58 -08:00
Erlend E. Aasland 5b9573eed4
gh-101578: Fixup NEWS and add What's New entry for new exception APIs (#102157) 2023-02-23 13:19:21 +01:00
Mark Shannon 22b8d77b98
GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749) 2023-02-23 10:19:01 +00:00
Irit Katriel 572223f9ce
Revert "bpo-46978: Correct docstrings for in-place builtin operators #31802) (#102146)
Revert "bpo-46978: Correct docstrings for in-place builtin operators (#31802)"

This reverts commit 128379b8cd.
2023-02-23 10:17:44 +00:00
Carl Meyer 056dfc71dc
gh-87634: remove locking from functools.cached_property (GH-101890)
Remove the undocumented locking capabilities of functools.cached_property.
2023-02-22 17:49:22 -08:00
Jonathan Protzenko fcadc7e405
gh-99108: Import MD5 and SHA1 from HACL* (#102089)
Replaces our fallback non-OpenSSL MD5 and SHA1 implementations with those from HACL* as we've already done with SHA2.
2023-02-22 13:18:43 -08:00
Mark Shannon 7c106a443f
GH-100982: Restrict `FOR_ITER_RANGE` to a single instruction to allow instrumentation. (GH-101985) 2023-02-22 11:11:57 +00:00
Eli Schwartz 3ba7743b06
gh-99942: python.pc on android/cygwin should link to libpython per configure.ac (GH-100356)
In commit 254b309c80 a previous change to avoid linking to libpython was partially reverted for Android (and later Cygwin as well), to add back the link flags. This was applied to distutils and to python-config.sh, but not to python.pc.

Add it back to python.pc as well.

Automerge-Triggered-By: GH:gpshead
2023-02-21 17:21:24 -08:00
Hyunkyun Moon d5c7954d0c
gh-95672 fix typo SkitTest to SkipTest (gh-102119)
Co-authored-by: HyunKyun Moon <hyunkyun.moon@linecorp.com>
2023-02-22 02:39:00 +09:00
Vo Hoang Long 0d4c7fcd4f
gh-101936: Update the default value of fp from io.StringIO to io.BytesIO (gh-102100)
Co-authored-by: Long Vo <long.vo@linecorp.com>
2023-02-22 00:14:41 +09:00
Gihwan Kim 6f25657b83
gh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (gh-102068) 2023-02-21 12:10:29 +09:00
Irit Katriel 022b44f254
gh-102056: Fix a few bugs in error handling of exception printing code (#102078) 2023-02-20 22:16:09 +00:00
Jason R. Coombs 36854bbb24
gh-101566: Sync with zipp 3.14. (GH-102018) 2023-02-20 13:01:58 -08:00
Tim Hatch 59e86caca8
gh-88233: zipfile: handle extras after a zip64 extra (GH-96161)
Previously, any data _after_ the zip64 extra would be removed.

With many new tests.

Fixes #88233

Automerge-Triggered-By: GH:jaraco
2023-02-20 09:07:03 -08:00
Steve Dower a99eb5cd99
gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)
* gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h

* Make cases_generator correct on Windows
2023-02-20 14:56:48 +00:00
Mark Dickinson b1b375e267
gh-97786: Fix compiler warnings in pytime.c (#101826)
Fixes compiler warnings in pytime.c.
2023-02-19 17:16:11 -08:00
Mark Dickinson b513c46d99
gh-85417: Clarify behaviour on branch cuts in cmath module (#102046)
This PR updates the cmath module documentation to reflect the reality that Python is almost always (and as far as I can tell, that "almost" can be omitted) running on a machine whose C double supports signed zeros.

* Removes misleading references to functions being continuous from above / below / the left / the right at branch cuts
* Expands the note on branch cuts at the top of the module documentation to explain the double-sided sign-of-zero-based behaviour
2023-02-19 19:15:44 +00:00
Furkan Onder 61f1e67c6f
GH-84783: Make the slice object hashable (GH-101264) 2023-02-18 18:22:02 -06:00
Jason R. Coombs 5170caf305
gh-97930: Apply changes from importlib_resources 5.12. (GH-102010) 2023-02-18 16:29:22 -05:00
Nicko van Someren 128379b8cd
bpo-46978: Correct docstrings for in-place builtin operators (#31802) 2023-02-18 18:44:41 +00:00
Eclips4 89413bbccb
gh-101967: add a missing error check (#101968) 2023-02-18 00:52:23 +00:00
Barney Gale 072011b3c3
gh-100809: Fix handling of drive-relative paths in pathlib.Path.absolute() (GH-100812)
Resolving the drive independently uses the OS API, which ensures it starts from the current directory on that drive.
2023-02-17 14:08:14 +00:00
Barney Gale d401b20630
gh-101360: Fix anchor matching in pathlib.PureWindowsPath.match() (GH-101363)
Use `fnmatch` to match path and pattern anchors, just as we do for other
path parts. This allows patterns such as `'*:/Users/*'` to be matched.
2023-02-17 14:05:38 +00:00
Yeojin Kim 3c0a31cbfd
Docs: fix typos in PyFunction_WatchCallback docs and in 3.12 NEWS (GH-101980)
- possitibility => possibility
- disaallowed => disallowed
2023-02-17 00:47:02 -08:00
Eric Snow 4d8959b73a
gh-101758: Add _PyState_AddModule() Back for the Stable ABI (gh-101956)
We're adding the function back, only for the stable ABI symbol and not as any form of API. I had removed it yesterday.

This undocumented "private" function was added with the implementation for PEP 3121 (3.0, 2007) for internal use and later moved out of the limited API (3.6, 2016) and then into the internal API (3.9, 2019). I removed it completely yesterday, including from the stable ABI manifest (where it was added because the symbol happened to be exported). It's unlikely that anyone is using _PyState_AddModule(), especially any stable ABI extensions built against 3.2-3.5, but we're playing it safe.

https://github.com/python/cpython/issues/101758
2023-02-16 14:05:31 -07:00
Kumar Aditya a5024a261a
GH-96764: rewrite `asyncio.wait_for` to use `asyncio.timeout` (#98518)
Changes `asyncio.wait_for` to use `asyncio.timeout` as its underlying implementation.
2023-02-17 00:18:21 +05:30
Eli Schwartz 226484e475
gh-99942: correct the pkg-config/python-config flags for cygwin/android 2023-02-16 17:57:59 +00:00
Eclips4 68bd8c5e2e
gh-101952: Fix possible segfault in `BUILD_SET` opcode (#101958) 2023-02-16 09:46:43 -08:00
Rayyan Ansari 739c026f44
gh-101881: Support (non-)blocking read/write functions on Windows pipes (GH-101882)
* fileutils: handle non-blocking pipe IO on Windows

Handle erroring operations on non-blocking pipes by reading the _doserrno code.
Limit writes on non-blocking pipes that are too large.

* Support blocking functions on Windows

Use the GetNamedPipeHandleState and SetNamedPipeHandleState Win32 API functions to add support for os.get_blocking and os.set_blocking.
2023-02-16 14:52:24 +00:00
Gregory P. Smith 0b13575e74
gh-99108: Refactor _sha256 & _sha512 into _sha2. (#101924)
This merges their code. They're backed by the same single HACL* static library, having them be a single module simplifies maintenance.

This should unbreak the wasm enscripten builds that currently fail due to linking in --whole-archive mode and the HACL* library appearing twice.

Long unnoticed error fixed: _sha512.SHA384Type was doubly assigned and was actually SHA512Type. Nobody depends on those internal names.

Also rename LIBHACL_ make vars to LIBHACL_SHA2_ in preperation for other future HACL things.
2023-02-15 22:08:20 -08:00
Eric Snow 89ac665891
gh-98627: Add an Optional Check for Extension Module Subinterpreter Compatibility (gh-99040)
Enforcing (optionally) the restriction set by PEP 489 makes sense. Furthermore, this sets the stage for a potential restriction related to a per-interpreter GIL.

This change includes the following:

* add tests for extension module subinterpreter compatibility
* add _PyInterpreterConfig.check_multi_interp_extensions
* add Py_RTFLAGS_MULTI_INTERP_EXTENSIONS
* add _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
* fail iff the module does not implement multi-phase init and the current interpreter is configured to check

https://github.com/python/cpython/issues/98627
2023-02-15 18:16:00 -07:00
Eric Snow b2fc549278
gh-101758: Clean Up Uses of Import State (gh-101919)
This change is almost entirely moving code around and hiding import state behind internal API.  We introduce no changes to behavior, nor to non-internal API.  (Since there was already going to be a lot of churn, I took this as an opportunity to re-organize import.c into topically-grouped sections of code.)  The motivation is to simplify a number of upcoming changes.

Specific changes:

* move existing import-related code to import.c, wherever possible
* add internal API for interacting with import state (both global and per-interpreter)
* use only API outside of import.c (to limit churn there when changing the location, etc.)
* consolidate the import-related state of PyInterpreterState into a single struct field (this changes layout slightly)
* add macros for import state in import.c (to simplify changing the location)
* group code in import.c into sections
*remove _PyState_AddModule()

https://github.com/python/cpython/issues/101758
2023-02-15 15:32:31 -07:00
Erlend E. Aasland c1ce0d178f
gh-99138: Isolate _zoneinfo (#99218)
* Convert zone info type to heap type and add it to module state
* Add global variables to module state
2023-02-15 22:58:48 +01:00
Erlend E. Aasland 8a2b7ee64d
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence (#101698) 2023-02-15 06:27:16 +01:00
Irit Katriel 81e3aa835c
gh-101799: implement PREP_RERAISE_STAR as an intrinsic function (#101800) 2023-02-14 11:54:13 +00:00
Jonathan Protzenko e5da9ab2c8
gh-99108: Import SHA2-384/512 from HACL* (#101707)
Replace the builtin hashlib implementations of SHA2-384 and SHA2-512
originally from LibTomCrypt with formally verified, side-channel resistant
code from the [HACL*](https://github.com/hacl-star/hacl-star/) project.
The builtins remain a fallback only used when OpenSSL does not provide them.
2023-02-14 01:25:16 -08:00
Sam James 8be8101bca
gh-101857: Allow xattr detection on musl libc (#101858)
Previously, we checked exclusively for `__GLIBC__` (AND'd with some other
conditions). Checking for `__linux__` instead should be fine.

This fixes using e.g. `os.listxattr()` on systems using musl libc.

Bug: https://bugs.gentoo.org/894130

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-02-13 23:21:58 -08:00
Radek Smejkal 928752ce4c
gh-74895: getaddrinfo no longer raises OverflowError (#2435)
`socket.getaddrinfo()` no longer raises `OverflowError` based on the **port** argument. Error reporting (or not) for its value is left up to the underlying C library `getaddrinfo()` implementation.
2023-02-13 17:37:34 -08:00
Steve Dower 0c6fe81dce
gh-101849: Add upgrade codes for old versions of launcher that ended up with later version numbers (GH-101877) 2023-02-13 20:33:48 +00:00
Mark Shannon 160f2fe2b9
GH-87849: Simplify stack effect of SEND and specialize it for generators and coroutines. (GH-101788) 2023-02-13 11:24:55 +00:00
Gregory P. Smith dfc2e065a2
gh-89792: Limit test_tools freeze test build parallelism based on the number of cores (#101841)
unhardcode freeze test build parallelism. base it on the number of cpus, don't use more than max(2, os.cpu_count()/3).
2023-02-11 22:07:52 -08:00
Soumendra Ganguly da2fb92643
gh-85984: Utilize new "winsize" functions from termios in pty tests. (#101831)
Utilize new functions termios.tcgetwinsize() and termios.tcsetwinsize in test_pty.py.

Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-02-11 21:24:43 -08:00
Gregory P. Smith 1d194235e4
gh-89792: Prevent test_tools from copying 1000M of "source" in freeze test (#101837)
Prevent test_tools from copying 1000M of "source"
    
It doesn't need a git repo, just the checkout.  We skip .git metadata, Doc/build, Doc/venv, and `__pycache__` subdirs, that developers often have in their clients to reduce the size of the source tree copy ten-fold.

This should significantly reduce IO and presumably time on buildbots during this long test.
2023-02-11 20:54:28 -08:00
Steve Dower e1aadedf09
gh-101763: Update bundled copy of libffi to 3.4.4 on Windows (GH-101784) 2023-02-10 16:57:30 +00:00
Irit Katriel 366b949058
gh-101517: make bdb avoid looking up in linecache with lineno=None (#101787) 2023-02-10 16:49:29 +00:00
Erlend E. Aasland 5d15224011
gh-101759: Update Windows installer to SQLite 3.40.1 (#101762) 2023-02-10 17:38:26 +01:00
Erlend E. Aasland 826bf0e695
gh-101277: Finalise isolating itertools (GH-101305)
Add repeat, islice, chain, tee, teedataobject, and batched types to module state.

Automerge-Triggered-By: GH:erlend-aasland
2023-02-10 03:58:14 -08:00
Erlend E. Aasland d40a23c0a1
gh-101759: Update macOS installer to SQLite 3.40.1 (#101761) 2023-02-10 08:25:02 +01:00
Dong-hee Na 5b946d3719
gh-101430: Update tracemalloc to handle presize properly. (gh-101745) 2023-02-10 08:30:03 +09:00
Gregory P. Smith b41c47cd06
gh-101726: Update the OpenSSL version to 1.1.1t (GH-101727)
Fixes CVE-2023-0286 (High) and a couple of Medium security issues.
https://www.openssl.org/news/secadv/20230207.txt
2023-02-09 17:40:51 +00:00
Mark Shannon ecfd2d37c5
GH-99293: Document that `Py_TPFLAGS_VALID_VERSION_TAG` shouldn't be used. (#GH-101736)
Document that Py_TPFLAGS_VALID_VERSION_TAG shouldn't be used.
2023-02-09 14:05:53 +01:00
Soumendra Ganguly 244d4cd9d2
gh-85984: Remove legacy Lib/pty.py code. (#92365)
Refactored the implementation of pty.fork to use os.login_tty.

A DeprecationWarning is now raised by pty.master_open() and pty.slave_open(). They were
undocumented and deprecated long long ago in the docstring in favor of pty.openpty.

Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-02-08 17:00:17 -08:00
Oleg Iarygin 23751ed826
gh-101283: Improved fallback logic for subprocess with shell=True on Windows (GH-101286) 2023-02-08 22:12:19 +00:00
Kumar Aditya d9de079248
GH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (#101697) 2023-02-08 23:32:15 +05:30
Michał Górny 2a8bf25804
gh-100221: Fix creating dirs in `make sharedinstall` (GH-100329)
Fix creating install directories in `make sharedinstall` if they exist already outside `DESTDIR`.  The previous make rules assumed that the directories would be created via a dependency on a rule for `$(DESTSHARED)` that did not fire if the directory did exist outside `$(DESTDIR)`.

While technically `$(DESTDIR)` could be prepended to the rule name, moving the rules for creating directories straight into the `sharedinstall` rule seems to fit the common practices better. Since the rule explicitly checks whether the individual directories exist anyway, there seems to be no reason to rely on make determining that implicitly as well.
2023-02-08 08:50:43 -08:00
Michael Droettboom 86ebd5c3fa
gh-101196: Make isdir/isfile/exists faster on Windows (GH-101324)
Co-authored-by: Eryk Sun <eryksun@gmail.com>
2023-02-08 14:34:24 +00:00
David Hewitt 3a88de7a0a
gh-101614: Don't treat python3_d.dll as a Python DLL when checking extension modules for incompatibility (GH-101615) 2023-02-08 14:23:57 +00:00
Mark Shannon feec49c407
GH-101578: Normalize the current exception (GH-101607)
* 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
2023-02-08 09:31:12 +00:00
Nikita Sobolev 790ff6bc6a
gh-101446: Change `repr` of `collections.OrderedDict` (#101661) 2023-02-07 20:01:10 -06:00
penguin_wwy 753fc8a5d6
gh-101632: Add the new RETURN_CONST opcode (#101633) 2023-02-07 22:32:21 +00:00
Thomas Wouters 0d3d5007b1 Merge branch 'main' of https://github.com/python/cpython into main 2023-02-07 23:13:53 +01:00
Oleg Iarygin f87f6e2396
gh-97725: Fix documentation for the default file of `asyncio.Task.print_stack` (#101652) 2023-02-07 23:34:31 +05:30
Thomas Wouters 3c67ec394f Python 3.12.0a5 2023-02-07 13:21:15 +01:00
Łukasz Langa 7990324048
[gh-101072] Fix Blurb for GH-101127 2023-02-07 10:50:39 +01:00
Matthieu Dartiailh ae62bddaf8
gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ (#101127)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-02-07 10:34:21 +01:00
Jonathan Protzenko 1fcc0efdaa
gh-99108: Replace SHA2-224 & 256 with verified code from HACL* (#99109)
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>
2023-02-06 18:11:01 -08:00
Eric Snow 132b3f8302
gh-59956: Partial Fix for GILState API Compatibility with Subinterpreters (gh-101431)
The GILState API (PEP 311) implementation from 2003 made the assumption that only one thread state would ever be used for any given OS thread, explicitly disregarding the case of subinterpreters.  However, PyThreadState_Swap() still facilitated switching between subinterpreters, meaning the "current" thread state (holding the GIL), and the GILState thread state could end up out of sync, causing problems (including crashes).

This change addresses the issue by keeping the two in sync in PyThreadState_Swap().  I verified the fix against gh-99040.

Note that the other GILState-subinterpreter incompatibility (with autoInterpreterState) is not resolved here.

https://github.com/python/cpython/issues/59956
2023-02-06 14:39:25 -07:00
Eclips4 b96b344f25
gh-101562: typing: add tests for inheritance with NotRequired & Required in parent fields (#101563) 2023-02-06 11:28:24 -08:00
Steve Dower 7a253103d4
gh-101543: Ensure Windows registry path is only used when stdlib can't be found (GH-101544) 2023-02-06 15:55:32 +00:00
Dong-hee Na 9ef7e75434
gh-101372: Fix unicodedata.is_normalized to properly handle the UCD 3… (gh-101388) 2023-02-06 13:58:00 +09:00
Ethan Furman ef7c2bfcf1
gh-101541: [Enum] create flag psuedo-member without calling original __new__ (GH-101590) 2023-02-05 19:29:06 -08:00