Commit Graph

29435 Commits

Author SHA1 Message Date
Pablo Galindo Salgado ac61d58db0
gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-06-24 14:08:12 +02:00
Serhiy Storchaka c38e2f64d0
gh-119614: Fix truncation of strings with embedded null characters in Tkinter (GH-120909)
Now the null character is always represented as \xc0\x80 for
Tcl_NewStringObj().
2024-06-24 12:17:25 +03:00
Serhiy Storchaka 1500a23f33
gh-120683: Fix an error in logging.LogRecord timestamp (GH-120709)
The integer part of the timestamp can be rounded up, while the millisecond
calculation truncates, causing the log timestamp to be wrong by up to 999 ms
(affected roughly 1 in 8 million timestamps).
2024-06-24 09:50:39 +03:00
Barney Gale 35e998f560
GH-73991: Add `pathlib.Path.copytree()` (#120718)
Add `pathlib.Path.copytree()` method, which recursively copies one
directory to another.

This differs from `shutil.copytree()` in the following respects:

1. Our method has a *follow_symlinks* argument, whereas shutil's has a
   *symlinks* argument with an inverted meaning.
2. Our method lacks something like a *copy_function* argument. It always
   uses `Path.copy()` to copy files.
3. Our method lacks something like a *ignore_dangling_symlinks* argument.
   Instead, users can filter out danging symlinks with *ignore*, or
   ignore exceptions with *on_error*
4. Our *ignore* argument is a callable that accepts a single path object,
   whereas shutil's accepts a path and a list of child filenames.
5. We add an *on_error* argument, which is a callable that accepts
   an `OSError` instance. (`Path.walk()` also accepts such a callable).

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
2024-06-23 22:01:12 +01:00
Jason R. Coombs 1ba0bb21ed
gh-120910: Fix issue resolving relative paths outside site-packages. (#120911)
Incorporates changes from importlib_metadata 7.2.1.
2024-06-23 13:06:07 -04:00
Serhiy Storchaka f4ddaa3967
gh-101830: Fix Tcl_Obj to string conversion (GH-120884)
Accessing the Tkinter object's string representation no longer converts
the underlying Tcl object to a string on Windows.
2024-06-23 16:34:14 +03:00
Sam Gross 8f17d69b7b
gh-119344: Make critical section API public (#119353)
This makes the following macros public as part of the non-limited C-API for
locking a single object or two objects at once.

* `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()`
* `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()`

The supporting functions and structs used by the macros are also exposed for
cases where C macros are not available.
2024-06-21 15:50:18 -04:00
Nice Zombies 1dadcb5a6a
Amend categories of @nineteendo's news entries (#120735) 2024-06-21 13:20:13 -05:00
Peter aed31beca9
gh-120811: Fix reference leak upon `_PyContext_Exit` failure (#120812)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-06-21 17:28:19 +00:00
neonene a81d434c06
gh-120782: Update internal type cache when reloading datetime (#120829) 2024-06-21 22:39:33 +05:30
Petr Viktorin 6f1d448bc1
gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520)
* Add an InternalDocs file describing how interning should work and how to use it.

* Add internal functions to *explicitly* request what kind of interning is done:
  - `_PyUnicode_InternMortal`
  - `_PyUnicode_InternImmortal`
  - `_PyUnicode_InternStatic`

* Switch uses of `PyUnicode_InternInPlace` to those.

* Disallow using `_Py_SetImmortal` on strings directly.
  You should use `_PyUnicode_InternImmortal` instead:
  - Strings should be interned before immortalization, otherwise you're possibly
    interning a immortalizing copy.
  - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to
    `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in
    backports, as they are now part of public API and version-specific ABI.

* Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.

* Make sure the statically allocated string singletons are unique. This means these sets are now disjoint:
  - `_Py_ID`
  - `_Py_STR` (including the empty string)
  - one-character latin-1 singletons

  Now, when you intern a singleton, that exact singleton will be interned.

* Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).

* Intern `_Py_STR` singletons at startup.

* For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup.

* Beef up the tests. Cover internal details (marked with `@cpython_only`).

* Add lots of assertions

Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-21 17:19:31 +02:00
Bénédikt Tran 7595e6743a
gh-120380: fix Python implementation of `pickle.Pickler` for `bytes` and `bytearray` objects in protocol version 5. (GH-120422) 2024-06-21 14:22:38 +02:00
Nikita Sobolev 8334a1b55c
gh-120384: Fix array-out-of-bounds crash in `list_ass_subscript` (#120442) 2024-06-21 13:48:38 +03:00
Jason R. Coombs 85d90b59e2
gh-120801: Refactor importlib.metadata fixtures. (#120803)
These changes released with importlib_metadata 7.2.0.
2024-06-20 19:00:39 +00:00
Tian Gao 31ce5c05a4
gh-120769: Add pdb meta command to print frame status. (#120770) 2024-06-20 10:38:07 -07:00
Sam Gross 3af7263037
gh-117511: Make PyMutex public in the non-limited API (#117731) 2024-06-20 11:29:08 -04:00
Jelle Zijlstra e8e151d471
gh-120780: Show attribute name for LOAD_SPECIAL in dis output (#120781) 2024-06-20 07:07:24 -07:00
Irit Katriel 55596ae044
gh-98442: fix locations of with statement's cleanup instructions (#120763)
gh-98442: fix location of with statement's cleanup instructions
2024-06-20 09:32:06 +01:00
Serhiy Storchaka 8bc76ae45f
gh-111259: Optimize complementary character sets in RE (GH-120742)
Patterns like "[\s\S]" or "\s|\S" which match any character are now compiled
to the same effective code as a dot with the DOTALL modifier ("(?s:.)").
2024-06-20 07:19:32 +00:00
Bénédikt Tran b8a8e04fec
gh-119698: fix `symtable.Class.get_methods` and document its behaviour correctly (#120151)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-19 20:49:30 -07:00
Xarblu 285f42c850
GH-120602: Support LLVM_VERSION_SUFFIX for JIT builds (GH-120604) 2024-06-19 17:48:00 -07:00
Tian Gao 4bbb0273f2
gh-120606: Allow EOF to exit pdb commands definition (#120607) 2024-06-19 15:50:26 -07:00
Nikita Sobolev 1e4815692f
gh-120732: Fix `name` passing to `Mock`, when using kwargs to `create_autospec` (#120737) 2024-06-19 21:35:11 +01:00
Mark Shannon d1c673b658
GH-120097: Make FrameLocalsProxy a mapping (#120101)
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
2024-06-19 17:54:13 +01:00
Mark Shannon 00257c746c
GH-119462: Enforce invariants of type versioning (GH-120731)
* Remove uses of Py_TPFLAGS_VALID_VERSION_TAG
2024-06-19 17:38:45 +01:00
Nadeshiko Manju f385d99f57
gh-120437: Fix `_CHECK_STACK_SPACE` optimization problems introduced in gh-118322 (GH-120712)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2024-06-19 23:34:39 +08:00
Jelle Zijlstra d8f27cb114
gh-120722: Set position on RETURN_VALUE in lambda (#120724) 2024-06-19 05:56:36 -07:00
Wulian233 89f7208f67
gh-120633: Move scrollbar and remove tear-off menus in turtledemo (#120634)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-06-19 02:20:54 -04:00
Diego Russo a0dce37895
GH-119726: Deduplicate JIT trampolines for out-of-range jumps (GH-120250) 2024-06-18 18:27:02 -07:00
Irit Katriel b7f478948f
gh-120367: fix bug where compiler detects redundant jump after pseudo op replacement (#120714) 2024-06-18 22:09:23 +00:00
Victor Stinner 49f51deeef
gh-120688: Build WASI with -O3 in debug mode (#120691)
On WASI in debug mode, Python is now built with compiler flag -O3
instead of -Og, to support more recursive calls.
2024-06-18 19:35:44 +02:00
devdanzin c81a5e6b5b
gh-119574: Add some missing environment variables to '--help-env'. (GH-120006) 2024-06-18 17:12:58 +00:00
Victor Stinner 16f8e22e7c
gh-120600: Make Py_TYPE() opaque in limited C API 3.14 (#120601)
In the limited C API 3.14 and newer, Py_TYPE() is now implemented as
an opaque function call to hide implementation details.
2024-06-18 14:28:48 +00:00
Sam Gross e8752d7b80
gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` (#118807)
This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable
C-API function to provide a thread-safe mechanism for clearing weakrefs
without executing callbacks.

Some C-API extensions need to clear weakrefs without calling callbacks,
such as after running finalizers like we do in subtype_dealloc.
Previously they could use `_PyWeakref_ClearRef` on each weakref, but
that's not thread-safe in the free-threaded build.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-06-18 09:57:23 -04:00
Jan Kaliszewski dacc5ac71a
gh-120381: Fix inspect.ismethoddescriptor() (#120383)
The `inspect.ismethoddescriptor()` function did not check for the lack of
`__delete__()` and, consequently, erroneously returned True when applied
to *data* descriptors with only `__get__()` and `__delete__()` defined.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-18 12:19:43 +00:00
Mark Shannon 9cefcc0ee7
GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. (#120640)
* Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions.

* Add LOAD_SPECIAL instruction

* Reimplement `with` and `async with` statements using LOAD_SPECIAL
2024-06-18 12:17:46 +01:00
Victor Stinner 5c4235cd8c
gh-119182: Add PyUnicodeWriter C API (#119184) 2024-06-17 17:10:52 +02:00
Steele Farnsworth 2c7209a3bd
gh-114091: Reword error message for unawaitable types (#114090)
Reword error message for unawaitable types.
2024-06-17 20:18:17 +05:30
Bénédikt Tran 4bf17c381f
gh-119933: Improve ``SyntaxError`` message for invalid type parameters expressions (#119976)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-17 06:51:03 -07:00
Irit Katriel 21866c8ed2
gh-120367: fix removal of redundant NOPs and jumps after reordering hot-cold blocks (#120425) 2024-06-17 10:10:06 +00:00
Idan Kapustian 192d17c3fd
gh-120485: Add an override of `allow_reuse_port` on classes subclassing `socketserver.TCPServer` (GH-120488)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2024-06-16 13:15:03 +01:00
Ruben Vorderman 08d09cf5ba
gh-112346: Always set OS byte to 255, simpler gzip.compress function. (GH-120486)
This matches the output behavior in 3.10 and earlier; the optimization in 3.11 allowed the zlib library's "os" value to be filled in instead in the circumstance when mtime was 0.  this keeps things consistent.
2024-06-15 18:46:39 +00:00
Serhiy Storchaka 31d1d72d7e
gh-120541: Improve the "less" prompt in pydoc (GH-120543)
When help() is called with non-string argument, use __qualname__ or
__name__ if available, otherwise use "{typename} object".
2024-06-15 20:56:40 +03:00
Wulian233 c501261c91
gh-120495: Fix incorrect exception handling in Tab Nanny (#120498)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-06-15 05:04:14 -06:00
Eric Snow b2e71ff4f8
gh-120161: Fix a Crash in the _datetime Module (gh-120182)
In gh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown.  However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection.  The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection.  To avoid the problem for _datetime, I have applied a similar approach here.

Also, credit goes to @mgorny and @neonene for the new tests.

FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting.  I'll circle back to the cleaner approach with a future change on the main branch.
2024-06-14 13:29:09 -06:00
Tian Gao ed60ab5fab
gh-119824: Print stack entry when user input is needed (#119882)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-06-14 11:25:23 -07:00
Barney Gale 7c38097add
GH-73991: Add `pathlib.Path.copy()` (#119058)
Add a `Path.copy()` method that copies the content of one file to another.

This method is similar to `shutil.copyfile()` but differs in the following ways:

- Uses `fcntl.FICLONE` where available (see GH-81338)
- Uses `os.copy_file_range` where available (see GH-81340)
- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.

The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.

Incorporates code from GH-81338 and GH-93152.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
2024-06-14 17:15:49 +01:00
Alex Waygood 42351c3b9a
gh-114053: Fix bad interaction of PEP 695, PEP 563 and `inspect.get_annotations` (#120270) 2024-06-13 21:16:40 +00:00
Bénédikt Tran a3711afefa
gh-120012: clarify the behaviour of `multiprocessing.Queue.empty` on closed queues. (GH-120102)
* improve doc for `multiprocessing.Queue.empty`
* add tests for checking emptiness of queues

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-06-13 19:03:01 +00:00
Kirill Podoprigora 6af190f8d0
gh-120397: Fix typo in NEWS entry (#120455) 2024-06-13 18:53:45 +02:00