Commit Graph

122703 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
Irit Katriel 65a12c559c
gh-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration (#120835) 2024-06-24 10:23:38 +01: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
Alek Kowalczyk fc297b4ba4
gh-112169: Documented getaddrinfo/getnameinfo default loop executor usage and implications. (#112191)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-06-24 08:35:02 +00: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
Serhiy Storchaka 02df679574
Use _PyLong_IsNegative instead of _PyLong_Sign if appropriate. (GH-120493)
It is faster and more obvious.
2024-06-24 09:49:01 +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
Hugo van Kemenade bc37ac7b44
Docs makefile/RTD: Use uv if installed (#120711) 2024-06-23 13:23:27 -06: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
Nyakku Shigure 0b918e81c1
Typing docs: normalize some indents in code examples (#120912) 2024-06-23 16:15:12 +00: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
Kumar Aditya 18b6ca9660
GH-120804: add docs for removal for asyncio child watchers (#120895)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-06-23 13:14:12 +00:00
Kumar Aditya 9d2e1ea386
GH-120804: Remove `PidfdChildWatcher`, `ThreadedChildWatcher` and `AbstractChildWatcher` from asyncio APIs (#120893) 2024-06-23 18:38:50 +05:30
Nice Zombies b6fa8fe86a
gh-120896: Fix typo in version changed note of `urllib.parse.urlparse()` (#120898) 2024-06-23 18:00:23 +05:30
Kumar Aditya 96ead91f0f
GH-120804: Remove `get_child_watcher` and `set_child_watcher` from asyncio (#120818) 2024-06-23 09:53:23 +05:30
Kumar Aditya 4717aaa1a7
GH-107803: double linked list implementation for asyncio tasks (GH-107804)
* linked list

* add tail optmiization to linked list

* wip

* wip

* wip

* more fixes

* finally it works

* add tests

* remove weakreflist

* add some comments

* reduce code duplication in _asynciomodule.c

* address some review comments

* add invariants about the state of the linked list

* add better explanation

* clinic regen

* reorder branches for better branch prediction

* Update Modules/_asynciomodule.c

* Apply suggestions from code review

Co-authored-by: Itamar Oren <itamarost@gmail.com>

* fix capturing of eager tasks

* add comment to task finalization

* fix tests and couple c implmentation to c task

improved linked-list logic and more comments

* fix test

---------

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2024-06-22 10:58:35 -07:00
Victor Stinner e213475495
gh-119182: Add checks to PyUnicodeWriter APIs (#120870) 2024-06-22 17:25:55 +02:00
Serhiy Storchaka a046c848c1
gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877) 2024-06-22 16:19:42 +03:00
Serhiy Storchaka 974a978631
gh-120873: Add test for "state" option in ttk.Scale (GH-120874)
Also refactor the "state" option tests for other ttk widgets.
2024-06-22 11:18:04 +00:00
Victor Stinner 879d1f28bb
gh-119182: Use PyUnicodeWriter_WriteWideChar() (#120851)
Use PyUnicodeWriter_WriteWideChar() in PyUnicode_FromFormat()
2024-06-22 08:58:22 +02:00
Serhiy Storchaka 6ad26de6e8
gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 (GH-120824)
The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
    option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-06-22 09:53:24 +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
Eric Snow 03fa2df927
gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (gh-120839) 2024-06-21 13:05:53 -06:00
Nice Zombies 462832041e
gh-119003: Clarify slice assignments (#119935) 2024-06-21 11:30:50 -07:00
Nice Zombies 1dadcb5a6a
Amend categories of @nineteendo's news entries (#120735) 2024-06-21 13:20:13 -05:00
Victor Stinner 913a956d85
gh-119182: Rewrite PyUnicodeWriter tests in Python (#120845) 2024-06-21 20:15:06 +02:00
Victor Stinner 4123226bbd
gh-119182: Add PyUnicodeWriter_DecodeUTF8Stateful() (#120639)
Add PyUnicodeWriter_WriteWideChar() and
PyUnicodeWriter_DecodeUTF8Stateful() functions.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-06-21 19:33:15 +02: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
blhsing 83d3d7aace
gh-120773: document introspective attributes of an async generator object in the inspect module (#120778) 2024-06-21 10:55:36 +00: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
Kumar Aditya 733dac01b0
GH-120804: Remove SafeChildWatcher, FastChildWatcher and MultiLoopChildWatcher from asyncio (#120805)
Remove SafeChildWatcher, FastChildWatcher and MultiLoopChildWatcher from asyncio. These child watchers have been deprecated since Python 3.12. The tests are also removed and some more tests will be added after the rewrite of child watchers.
2024-06-21 10:23:10 +05:30
Serhiy Storchaka a2f6f7dd26
gh-111259: Document idiomatic RE pattern (?s:.) that matches any character (GH-120745) 2024-06-21 00:03:49 +03:00
Victor Stinner 56657f6be2
gh-119182: Use public PyUnicodeWriter in contextvar_tp_repr() (#120809)
The public PyUnicodeWriter API enables overallocation by default and
so is more efficient. It also makes the code simpler and shorter.
2024-06-20 19:56:47 +00:00
Victor Stinner 5150795b1c
gh-119182: Optimize PyUnicode_FromFormat() (#120796)
Use strchr() and ucs1lib_find_max_char() to optimize the code path
formatting sub-strings between '%' formats.
2024-06-20 19:06:16 +00: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
Victor Stinner c1553bc34a
gh-119182: Use public PyUnicodeWriter API in union_repr() (#120797)
The public PyUnicodeWriter API enables overallocation by default and
so is more efficient.

Benchmark:

python -m pyperf timeit \
    -s 't = int | float | complex | str | bytes | bytearray' \
       ' | memoryview | list | dict' \
    'str(t)'

Result:

1.29 us +- 0.02 us -> 1.00 us +- 0.02 us: 1.29x faster
2024-06-20 20:39:34 +02:00
Victor Stinner 73b4492c19
gh-119182: Use public PyUnicodeWriter API in ga_repr() (#120799)
The public PyUnicodeWriter API enables overallocation by default and
so is more efficient.

Benchmark:

python -m pyperf timeit \
    -s 't = list[int, float, complex, str, bytes, bytearray, ' \
                 'memoryview, list, dict]' \
    'str(t)'

Result:

1.49 us +- 0.03 us -> 1.10 us +- 0.02 us: 1.35x faster
2024-06-20 20:35:35 +02: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
Jelle Zijlstra 3846fcfb92
gh-119698: symtable: Fix merge race (#120779) 2024-06-20 05:42:30 +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
Xie Yanbo 656a1c8108
Fix typos in comments (#120481) 2024-06-19 23:16:14 -04: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