Commit Graph

123392 Commits

Author SHA1 Message Date
Serhiy Storchaka 1a0b828994
gh-122561: Clean up and microoptimize str.translate and charmap codec (GH-122932)
* Replace PyLong_AS_LONG() with PyLong_AsLong().
* Call PyLong_AsLong() only once per the replacement code.
* Use PyMapping_GetOptionalItem() instead of PyObject_GetItem().
2024-08-28 12:11:13 +03:00
sobolevn 6f563e364d
gh-123254: Improve `tuple` C API docs with more info about errors (#123255)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-08-28 10:30:21 +03:00
Alexandr Mitin 6a7765b9fa
gh-123363: Show string value of CONTAINS_OP oparg in dis (#123387)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-08-28 09:15:34 +03:00
Jason R. Coombs 2231286d78
gh-123270: Replaced SanitizedNames with a more surgical fix. (#123354)
Applies changes from zipp 3.20.1 and jaraco/zipp#124
2024-08-27 17:10:30 -04:00
Pieter Eendebak 7e38e6745d
gh-123271: Make builtin zip method safe under free-threading (#123272)
The `zip_next` function uses a common optimization technique for methods
that generate tuples. The iterator maintains an internal reference to
the returned tuple. When the method is called again, it checks if the
internal tuple's reference count is 1. If so, the tuple can be reused.
However, this approach is not safe under the free-threading build:
after checking the reference count, another thread may perform the same
check and also reuse the tuple. This can result in a double decref on
the items of the replaced tuple and a double incref (memory leak) on
the items of the tuple being set.

This adds a function, `_PyObject_IsUniquelyReferenced` that
encapsulates the stricter logic necessary for the free-threaded build:
the internal tuple must be owned by the current thread, have a local
refcount of one, and a shared refcount of zero.
2024-08-27 15:22:43 -04:00
Irit Katriel d24d1c986d
gh-121404: split compiler_nameop into a codegen part and a compiler part (#123398) 2024-08-27 16:57:31 +01:00
Daniel Hollas 08c0166ce4
gh-109975: Fix a typo in What's New in Python 3.13 (#123393) 2024-08-27 15:53:45 +01:00
Mark Shannon f49a91648a
GH-117759: Document incremental GC (GH-123266)
* Update what's new

* Update gc module docs and fix inconsistency in gc.get_objects
2024-08-27 15:23:39 +01:00
Kumar Aditya 460ee5b994
gH-80788: remove old weakset workaround for thread safety (#123388) 2024-08-27 19:12:44 +05:30
Kumar Aditya 03f5abf15a
gh-123089: Make weakref.WeakSet safe against concurrent mutations while it is being iterated (#123279)
* Make `weakref.WeakSet` safe against concurrent mutations while it is being iterated.

`_IterationGuard` is no longer used for `WeakSet`, it now relies on copying the underlying set which is an atomic operation while iterating so that it can be modified by other threads.
2024-08-27 13:04:03 +00:00
Petr Viktorin 6754566a51
gh-120426: Reword the glossary term "immortal" (GH-123191)
Reword the glossary term "immortal", mark it as an implementation detail
2024-08-27 13:37:56 +02:00
Irit Katriel da4302699f
gh-121404: compiler_visit_* --> codegen_visit_* (#123382) 2024-08-27 11:32:24 +00:00
Mark Shannon 54a05a4600
GH-123232: Factor BINARY_SLICE and STORE_SLICE to handle stats properly for tier 2. (GH-123381) 2024-08-27 10:49:39 +01:00
Mark Shannon 89328f7b12
GH-115775: Use `__static_attributes__` to initialize shared keys (GH-118468) 2024-08-27 10:34:46 +01:00
Terry Jan Reedy fe85a8291d
Further revise idlelib/Icons/README.text (#123364)
In particular, add trademark derivative approval information.
2024-08-26 17:44:35 -04:00
Kirill Podoprigora 9f9b00d52c
gh-122666: Tests for ast optimizations (#122667)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-08-26 19:27:22 +00:00
sobolevn 1eed0f968f
gh-123340: Show string value of `IS_OP` oparg in `dis` (#123348) 2024-08-26 21:59:50 +03:00
Barney Gale 7bd6ebf696
GH-73991: Prune `pathlib.Path.copy()` and `copy_into()` arguments (#123337)
Remove *ignore* and *on_error* arguments from `pathlib.Path.copy[_into]()`,
because these arguments are under-designed. Specifically:

- *ignore* is appropriated from `shutil.copytree()`, but it's not clear
  how it should apply when the user copies a non-directory. We've changed
  the callback signature from the `shutil` version, but I'm not confident
  the new signature is as good as it can be.
- *on_error* is a generalisation of `shutil.copytree()`'s error handling,
  which is to accumulate exceptions and raise a single `shutil.Error` at
  the end. It's not obvious which solution is better.

Additionally, this arguments may be challenging to implement in future user
subclasses of `PathBase`, which might utilise a native recursive copying
method.
2024-08-26 17:05:34 +01:00
Barney Gale 033d537cd4
GH-73991: Make `pathlib.Path.delete()` private. (#123315)
Per feedback from Paul Moore on GH-123158, it's better to defer making
`Path.delete()` public than ship it with under-designed error handling
capabilities.

We leave a remnant `_delete()` method, which is used by `move()`. Any
functionality not needed by `move()` is deleted.
2024-08-26 16:26:34 +01:00
Victor Stinner a1ddaaef58
gh-111495: Remove test_capi test_rshift_print() (#123338)
The suggestion for "print >> value" was removed recently:
commit 9375b9ca3a.
2024-08-26 14:39:32 +00:00
Sergey B Kirpichev 2f20f5a9bc
gh-111495: Add tests for PyNumber C API (#111996) 2024-08-26 15:59:22 +02:00
Barney Gale c68a93c582
GH-73991: Add `pathlib.Path.copy_into()` and `move_into()` (#123314)
These two methods accept an *existing* directory path, onto which we join
the source path's base name to form the final target path.

A possible alternative implementation is to check for directories in
`copy()` and `move()` and adjust the target path, which is done in several
`shutil` functions. This behaviour is helpful in a shell context, but
less so in a stored program that explicitly specifies destinations. For
example, a user that calls `Path('foo.py').copy('bar.py')` might not
imagine that `bar.py/foo.py` would be created, but under the alternative
implementation this will happen if `bar.py` is an existing directory.
2024-08-26 14:14:23 +01:00
Sergey B Kirpichev dbc1752d41
gh-111495: Add tests for PyTuple C API (#118757)
Co-authored-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-08-26 11:57:52 +02:00
Terry Jan Reedy 6401cdf908
Rewrite idlelib/Icons/README.txt (#123329) 2024-08-25 22:11:59 -04:00
Matt Wozniski 602fcf97df
gh-123177: Fix prompt for wrapped lines in pyrepl (#123324)
When display lines above the cursor come from the cache, the first line
to not come from the cache may be a wrapped line, starting half way
through a logical line in the buffer. Detect and handle this case to
avoid accidentally drawing a stray prompt in the middle of a logical
line.
2024-08-25 22:54:06 +00:00
CF Bolz-Tereick 70bfef52b5
gh-82378: Document the difference between sys.tracebacklimit and the limit arguments (#123286) 2024-08-25 23:50:43 +01:00
Pablo Galindo Salgado fdb3f9b588
gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the new REPL (#123267) 2024-08-25 22:38:49 +01:00
Pablo Galindo Salgado c535a49e92
gh-123297: Propagate LD_FLAGS to LDCXXSHARED in sysconfig (#123298) 2024-08-25 21:01:58 +01:00
Kirill Podoprigora 249b083ed8
gh-122982: Extend the deprecation period for bool inversion by two years (#123306) 2024-08-25 12:24:44 -07:00
Barney Gale 625d0705b9
GH-73991: Add `pathlib.Path.move()` (#122073)
Add a `Path.move()` method that moves a file or directory tree, and returns a new `Path` instance pointing to the target.

This method is similar to `shutil.move()`, except that it doesn't accept a *copy_function* argument, and it doesn't check whether the destination is an existing directory.
2024-08-25 16:51:51 +01:00
CF Bolz-Tereick aa905925e1
gh-123228: don't leak file descriptors in pyrepl test (#123302) 2024-08-25 15:52:51 +01:00
Adam Turner 74ff496dce
GH-109975: Copyedit 3.13 What's New: Optimizations (#123301) 2024-08-25 16:17:46 +03:00
Adam Turner 9b3749849e
GH-123299: Move ctypes What's New entry to 3.14 (#123300) 2024-08-25 01:41:44 +01:00
Shantanu 52caaef6d0
Revert "GH-120754: Add a strace helper and test set of syscalls for o… (#123303)
Revert "GH-120754: Add a strace helper and test set of syscalls for open().read() (#121143)"

This reverts commit e38d0afe35.
2024-08-24 21:54:31 +00:00
Cody Maloney e38d0afe35
GH-120754: Add a strace helper and test set of syscalls for open().read() (#121143) 2024-08-24 13:42:41 -07:00
Anthony Shaw 86f06cb3fb
Remove comment from pystate created in 2003 (#123259) 2024-08-24 20:36:42 +00:00
Sergey B Kirpichev ca18ff2a34
gh-123228: fix return type for _ReadlineWrapper.get_line_buffer() (#123281)
Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
2024-08-24 17:46:05 +02:00
Barney Gale c4ee4e756a
GH-122890: Fix low-level error handling in `pathlib.Path.copy()` (#122897)
Give unique names to our low-level FD copying functions, and try each one
in turn. Handle errors appropriately for each implementation:

- `fcntl.FICLONE`: suppress `EBADF`, `EOPNOTSUPP`, `ETXTBSY`, `EXDEV`
- `posix._fcopyfile`: suppress `EBADF`, `ENOTSUP`
- `os.copy_file_range`: suppress `ETXTBSY`, `EXDEV`
- `os.sendfile`: suppress `ENOTSOCK`
2024-08-24 15:11:39 +01:00
Adam Turner 127660bcdb
GH-109975: Copyedit 3.13 What's New: Improved Modules (#123132)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-08-24 14:32:35 +01:00
Adam Turner b178beef26
Docs: Fix Makefile syntax (#123287) 2024-08-24 12:57:38 +00:00
neonene 5ff638f1b5
gh-123243: Fix reference leak in `_decimal` (#123244) 2024-08-24 09:37:01 +05:30
Sam Gross 556e855684
gh-117376: Make `Py_DECREF` a macro in ceval.c in free-threaded build (#122975)
`Py_DECREF` and `PyStackRef_CLOSE` are now implemented as macros in the
free-threaded build in ceval.c. There are two motivations;

 * MSVC has problems inlining functions in ceval.c in the PGO build.

 * We will want to mark escaping calls in order to spill the stack
   pointer in ceval.c and we will want to do this around `_Py_Dealloc`
   (or `_Py_MergeZeroLocalRefcount` or `_Py_DecRefShared`), not around
   the entire `Py_DECREF` or `PyStackRef_CLOSE` call.
2024-08-23 15:36:14 -04:00
Kirill Podoprigora 67f2c84bff
gh-123205: `Python/bytecodes.c`: Fix compiler warning (#123206)
Fix MSVC warning "conversion from '__int64' to 'int'"
2024-08-23 15:35:25 -04:00
Barney Gale d7ae4dc5c1
GH-73991: Disallow copying directory into itself via `pathlib.Path.copy()` (#122924) 2024-08-23 20:03:11 +01:00
Irit Katriel bf1b5d323b
gh-121404: more compiler_* -> codegen_*, class_body and comprehensions (#123262) 2024-08-23 19:53:15 +01:00
Kevin Evans 58fdb169c8
Fix typo mentioning threads instead of tasks (#123203) 2024-08-23 21:54:12 +05:30
blhsing 126910edba
gh-122272: Guarantee specifiers %F and %C for datetime.strftime to be 0-padded (GH-122436) 2024-08-23 18:45:03 +03:00
Mark Shannon 7cd3aa42f0
GH-122298: Restore printing of GC stats (GH-123261) 2024-08-23 16:39:08 +01:00
Pablo Galindo Salgado adc5190014
gh-123229: Fix valgrind warning by initializing the f-string buffers to 0 in the tokenizer (#123263)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2024-08-23 12:33:45 +00:00
Mark Shannon 0b0f7befad
GH-123232: Fix "not specialized" stats (GH-123236) 2024-08-23 10:46:03 +01:00