Commit Graph

53015 Commits

Author SHA1 Message Date
Kirill Podoprigora 5901d92739
gh-122096: Remove accidentally left debugging prints (#122097) 2024-07-21 20:48:39 +01:00
Barney Gale c4c7097e64
GH-73991: Support preserving metadata in `pathlib.Path.copytree()` (#121438)
Add *preserve_metadata* keyword-only argument to `pathlib.Path.copytree()`,
defaulting to false. When set to true, we copy timestamps, permissions,
extended attributes and flags where available, like `shutil.copystat()`.
2024-07-20 23:32:52 +01:00
Barney Gale 094375b9b7
GH-73991: Add `pathlib.Path.rmtree()` (#119060)
Add a `Path.rmtree()` method that removes an entire directory tree, like
`shutil.rmtree()`. The signature of the optional *on_error* argument
matches the `Path.walk()` argument of the same name, but differs from the
*onexc* and *onerror* arguments to `shutil.rmtree()`. Consistency within
pathlib is probably more important.

In the private pathlib ABCs, we add an implementation based on `walk()`.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-20 20:14:13 +00:00
Sam Gross a09e215abf
gh-121988: Fix test hang when pyrepl is not available (#121990)
Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.
2024-07-20 16:04:14 +02:00
Pablo Galindo Salgado 2009e25e26
gh-122026: Fix identification of mismatched parentheses inside f-strings (#122028) 2024-07-19 19:08:08 +02:00
Karolina Surma 186b4d8ea2
gh-122014: Account for abi_thread in test_sysconfig.test_user_similar (gh-122017) 2024-07-19 16:48:20 +00:00
Rodrigo Oliveira d66b06107b
gh-118830: Bump pickle.DEFAULT_PROTOCOL to 5 (GH-119340) 2024-07-19 16:47:10 +02:00
Serhiy Storchaka 1a0c7b9ba4
gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) 2024-07-19 08:06:02 +00:00
Serhiy Storchaka c8d2630995
gh-82017: Support as_integer_ratio() in the Fraction constructor (GH-120271)
Any objects that have the as_integer_ratio() method (e.g. numpy.float128)
can now be converted to a fraction.
2024-07-19 08:06:53 +03:00
Tian Gao 1ab1778283
gh-120289: Disallow disable() and clear() in external timer to prevent use-after-free (#120297) 2024-07-18 12:47:22 -07:00
Matthieu Caneill cecaceea31
gh-120930: Remove extra blank occuring in wrapped encoded words in email headers (GH-121747) 2024-07-18 14:48:05 +02:00
Gregor 1056f2bc20
gh-121657: Additional `yield from` error test using lambda (GH-121722) 2024-07-18 14:29:03 +02:00
Mark Shannon 3eacfc1a4d
GH-121784: Generate an error during code gen if a variable is marked `unused`, but is used and thus cached in a prior uop. (#121788)
* Reject uop definitions that declare values as 'unused' that are already cached by prior uops

* Track which variables are defined and only load from memory when needed

* Support explicit `flush` in macro definitions. 

* Make sure stack is flushed in where needed.
2024-07-18 12:49:24 +01:00
Mark Shannon 169324c27a
GH-120024: Use pointer for stack pointer (GH-121923) 2024-07-18 12:47:21 +01:00
Jelle Zijlstra 63ddd28cf3
gh-121921: Make bogus_code_obj.py crash the interpreter (#121922) 2024-07-18 04:02:08 -04:00
Łukasz Langa 19cbf8fd63
gh-120678: Guard against stdin.fileno() being unavailable (#121924) 2024-07-17 16:05:34 +00:00
Alex Waygood ac07451116
gh-120678: pyrepl: Include globals from modules passed with `-i` (GH-120904)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-17 16:18:42 +02:00
Terry Jan Reedy 58753f33e4
gh-78889: Stop IDLE Shell freezes from sys.stdout.shell.xyz (#121876)
Problem occurred when attribute xyz could not be pickled.
Since this is not trivial to selectively fix, block all
attributes (other than 'width').  IDLE does not access them
and they are private implementation details.
2024-07-17 09:33:33 -04:00
Bénédikt Tran 6682d91678
gh-119698: fix a special case in `symtable.Class.get_methods` (#121802) 2024-07-17 06:27:35 -07:00
Petr Viktorin cffad5c6ef
gh-121863: Immortalize names in code objects to avoid crash (GH-121903) 2024-07-17 11:31:28 +02:00
Victor Stinner bfdbeac355
gh-121849: Fix PyUnicodeWriter_WriteSubstring() crash if len=0 (#121896)
Do nothing if start=end.
2024-07-17 10:26:05 +02:00
Michael dc9cc91f76
Fix Several Typos in Readme & Tests (#121559) 2024-07-17 00:24:35 -07:00
sobolevn f6c7d8d79c
gh-121842: Improve coverage of `PyBytes_FromStringAndSize` (#121843) 2024-07-17 10:00:07 +03:00
Tian Gao e65cb4c6f0
gh-118934: Make PyEval_GetLocals return borrowed reference (#119769)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-07-16 12:17:47 -07:00
Sam Gross 162b41f577
gh-121860: Fix crash when materializing managed dict (#121866)
The object's inline values may be marked invalid if the materialized
dict was already initialized and then deleted.
2024-07-16 14:58:36 -04:00
Pablo Galindo Salgado c46d64e0ef
gh-121130: Fix f-string format specifiers with debug expressions (#121150) 2024-07-16 19:57:22 +01:00
Andreas Stocker 8f2532168b
gh-59022: Added tests for `pkgutil.extend_path` (#59022) (GH-121673)
This adds tests for the documented behaviour of `pkgutil.extend_path`
regarding different argument types as well as for `*.pkg` files.
2024-07-16 17:14:26 +02:00
Petr Viktorin 263c7e611b
gh-121160: Add some tests for readline.set_history_length (GH-121326) 2024-07-16 16:09:08 +02:00
Lysandros Nikolaou 8549559f38
gh-120317: Lock around global state in the tokenize module (#120318)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2024-07-16 11:35:57 +02:00
Marta Gómez Macías 498a94c198
gh-121295: Fix blocked console after interrupting a long paste (GH-121815) 2024-07-16 01:38:54 +02:00
saucoide 7d111dac16
gh-121610: pyrepl - handle extending blocks when multi-statement blocks are pasted (GH-121757)
console.compile with the "single" param throws an exception when
there are multiple statements, never allowing to adding newlines
to a pasted code block (gh-121610)

This add a few extra checks to allow extending when in an indented
block, and tests for a few examples

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-16 01:33:57 +02:00
Sam Gross 4134261ab8
gh-121605: Fix test hang when pyrepl is not available (GH-121820)
The fallback repl does not support "exit" without parentheses, so the
test would hang until the timeout expired.
2024-07-16 00:50:16 +02:00
Milan Oberkirch e5c7216f37
gh-121790: Fix interactive console initialization (#121793)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-16 00:24:18 +02:00
Sam Gross 82a4dac9f6
gh-117657: Skip tests that fork with threads under TSan (#121599)
This avoids messages like:

  ThreadSanitizer: starting new threads after multi-threaded fork is not
  supported. Dying (set die_after_fork=0 to override)
2024-07-15 16:43:51 -04:00
Sergey B Kirpichev 05d413764c
gh-121245: Refactor site.register_readline() (GH-121659)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-15 22:12:41 +02:00
Eric Snow 8b209fd4f8
gh-76785: Expand How Interpreter Channels Handle Interpreter Finalization (gh-121805)
See 6b98b274b6 for an explanation of the problem and solution.  Here I've applied the solution to channels.
2024-07-15 19:43:59 +00:00
Sergey B Kirpichev fd085a411e
gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain (GH-121672)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-15 21:21:49 +02:00
Eric Snow 6b98b274b6
gh-76785: Expand How Interpreter Queues Handle Interpreter Finalization (gh-116431)
Any cross-interpreter mechanism for passing objects between interpreters must be very careful to respect isolation, even when the object is effectively immutable (e.g. int, str).  Here this especially relates to when an interpreter sends one of its objects, and then is destroyed while the inter-interpreter machinery (e.g. queue) still holds a reference to the object.

When I added interpreters.Queue, I dealt with that case (using an atexit hook) by silently removing all items from the queue that were added by the finalizing interpreter.

Later, while working on concurrent.futures.InterpreterPoolExecutor (gh-116430), I noticed it was somewhat surprising when items were silently removed from the queue when the originating interpreter was destroyed.  (See my comment on that PR.) 
 It took me a little while to realize what was going on.  I expect that users, which much less context than I have, would experience the same pain.

My approach, here, to improving the situation is to give users three options:

1. return a singleton (interpreters.queues.UNBOUND) from Queue.get() in place of each removed item
2. raise an exception (interpreters.queues.ItemInterpreterDestroyed) from Queue.get() in place of each removed item
3. existing behavior: silently remove each item (i.e. Queue.get() skips each one)

The default will now be (1), but users can still explicitly opt in any of them, including to the silent removal behavior.

The behavior for each item may be set with the corresponding Queue.put() call. and a queue-wide default may be set when the queue is created.  (This is the same as I did for "synconly".)
2024-07-15 12:49:23 -06:00
Rodrigo Girão Serrão 6522f0e438
gh-121746: Bind Alt+Enter to "accept" in the REPL (GH-121754) 2024-07-15 19:47:56 +02:00
Sebastian Rittau 74fbdcd74a
gh-121785: Remove unused code from codecs.py (GH-121787)
It was only needed for non-Unicode Python builds,
which aren't supported anymore.
2024-07-15 17:18:37 +00:00
Serhiy Storchaka 94bee45dee
gh-84978: Add float.from_number() and complex.from_number() (GH-26827)
They are alternate constructors which only accept numbers
(including objects with special methods __float__, __complex__
and __index__), but not strings.
2024-07-15 16:07:00 +00:00
Dominic H 8303d32ff5
gh-117765: Improve documentation for `mocker.patch.dict` (#121755) 2024-07-15 07:14:17 +00:00
Kumar Aditya 48042c52a6
fix outdated comments in asyncio (#121783) 2024-07-15 05:59:19 +00:00
Jelle Zijlstra 50eec501fe
gh-57141: Make shallow argument to filecmp.dircmp keyword-only (#121767)
It is our general practice to make new optional parameters keyword-only,
even if the existing parameters are all positional-or-keyword. Passing
this parameter as positional would look confusing and could be error-prone
if additional parameters are added in the future.
2024-07-14 15:53:32 -07:00
Tomas R 901ea411bf
gh-121708: Improve test coverage for `unittest.util` (GH-121713) 2024-07-14 10:08:47 +02:00
Tian Gao c0af6d4ff1
gh-121651: Fix pdb header test (#121724) 2024-07-13 11:55:22 -07:00
Milan Oberkirch a183474293
gh-121711: Set `-m asyncio` return_code to 1 for ENOTTY (#121714)
Set return_code to 1 for ENOTTY
2024-07-13 17:17:24 +02:00
Gregor 178e44de8f
gh-121657: Display correct error message for yield from outside of a function (GH-121680)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-13 17:14:39 +02:00
Sam Gross abc3aeebdb
gh-121605: Increase timeout in test_pyrepl.run_repl (#121606)
We also need to close the `slave_fd` earlier so that reading from
`master_fd` won't block forever when the subprocess finishes.
2024-07-13 15:54:28 +02:00
Tomas R 0a26aa5007
gh-121671: Increase test coverage of `ast.get_docstring` (GH-121674)
Increase test coverage for `ast.get_docstring`
2024-07-13 14:59:15 +02:00