Commit Graph

122445 Commits

Author SHA1 Message Date
Raymond Hettinger ce2ea7d629
Minor speed/accuracy improvement for kde() (gh-119910) 2024-06-01 10:49:14 -05:00
Sam Gross 90ec19fd33
gh-117657: Fix TSAN race in QSBR assertion (#119887)
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
2024-06-01 10:04:38 -04:00
Sam Gross 60593b2052
gh-117657: Fix TSAN race in free-threaded GC (#119883)
Only call `gc_restore_tid()` from stop-the-world contexts.
`worklist_pop()` can be called while other threads are running, so use a
relaxed atomic to modify `ob_tid`.
2024-06-01 10:04:05 -04:00
dependabot[bot] 5152120ae7
Bump types-psutil from 5.9.5.20240423 to 5.9.5.20240516 in /Tools (#119900) 2024-06-01 10:38:13 +00:00
dependabot[bot] 51191dbfdd
build(deps-dev): bump types-setuptools from 69.5.0.20240423 to 70.0.0.20240524 in /Tools (#119899) 2024-06-01 10:11:53 +00:00
Alyssa Coghlan 2180991ea3
gh-118888: Further PEP 667 docs updates (gh-119893)
* Clarify impact on default behaviour of exec, eval, etc
* Update documentation for changes to PyEval_GetLocals (gh-74929)

Closes gh-11888
2024-06-01 16:21:48 +10:00
Alyssa Coghlan 3859e09e3d
gh-74929: PEP 667 C API documentation (gh-119379)
* Add docs for new APIs
* Add soft-deprecation notices
* Add What's New porting entries
* Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead
* Other related cleanups found when looking for refs to the deprecated APIs
2024-06-01 13:59:35 +10:00
Raymond Hettinger cc5cd4d93e
statistics.fmean(): speed-up code path for non-sizeable inputs. (gh-119876) 2024-05-31 17:08:55 -05:00
Jelle Zijlstra d28afd3fa0
gh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864) 2024-05-31 14:05:51 -07:00
Jelle Zijlstra 80a4e38994
gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822)
Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS

The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated,
but that seems like it may get hairy since the two operations have different operands.

This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too,
and we should backport to 3.13 and 3.12 if possible.
2024-05-31 14:05:24 -07:00
Łukasz Langa 2237946af0
gh-118894: Make asyncio REPL use pyrepl (GH-119433) 2024-05-31 22:26:02 +02:00
Victor Stinner f9d47fed9f
gh-119853: Add Include/refcount.h to projects (#119860) 2024-05-31 21:21:30 +02:00
Sam Gross 879d43b705
gh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (#119800)
The free-threaded refleak builds were reporting negative refcount deltas
in some tests because of a missing `_Py_NewRefWithLock`.
2024-05-31 14:18:24 -04:00
Sam Gross 9bc6045842
doc: Add glossary entry for "free threading" (#119865) 2024-05-31 13:23:29 -04:00
Zachary Ware f3fc800d5f
contextlib docs: Clean up redundant 'up' after 'cleanup' (GH-119867)
Reported by Michael Kass on docs@
2024-05-31 17:19:54 +00:00
Irit Katriel 015b1fdd0a
gh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field. (#119364) 2024-05-31 17:09:48 +00:00
Sam Gross 078b8c8cf2
gh-119369: Fix deadlock during thread exit in free-threaded build (#119528)
Release the GIL before calling `_Py_qsbr_unregister`.

The deadlock could occur when the GIL was enabled at runtime. The
`_Py_qsbr_unregister` call might block while holding the GIL because the
thread state was not active, but the GIL was still held.
2024-05-31 13:04:59 -04:00
Victor Stinner 64ff1e217d
gh-119770: Make termios ioctl() constants positive (#119840) 2024-05-31 17:18:40 +02:00
Sam Gross bcc1be39cb
gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (#119753)
Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
2024-05-31 10:50:52 -04:00
Victor Stinner 891c1e36f4
gh-119853: Add Include/refcount.h file (#119854) 2024-05-31 16:49:26 +02:00
Victor Stinner 91601a5596
gh-111201: Skip pyrepl Windows tests earlier (#119848)
Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.
2024-05-31 14:06:10 +00:00
Łukasz Langa 4c387a76f3
gh-111201: [pyrepl] Ensure optional platform-specific imports are optional (GH-119834) 2024-05-31 14:41:26 +02:00
Steve Dower 0e8d35b931
gh-116145: Updated bundled Tcl/Tk on Windows to 8.6.14 (GH-117030) 2024-05-31 13:07:19 +01:00
Joshua Herman b9965ef282
gh-119189: Fix the power operator for Fraction (GH-119242)
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
2024-05-31 10:05:09 +00:00
Arnon Yaari dae0375bd9
gh-111201: Improve pyrepl auto indentation (#119606)
- auto-indent when editing multi-line block
- ignore comments
2024-05-31 11:02:54 +02:00
Christopher Chavez 94e9585e99
gh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 (GH-103846)
Some of standard Tcl types were renamed, removed, or no longer
registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl
values to Python values to avoid returning a Tcl_Obj where the primary
Python types (int, bool, str, bytes) were returned in older Tcl.
2024-05-31 11:23:53 +03:00
Sergey B Kirpichev b278c723d7
gh-119780: Adjust exception messages in Lib/test/test_format.py (GH-119781)
Mismatches were just output to the stdout, without making the test failing.
2024-05-31 11:07:16 +03:00
Katie Bell 010aaa32fb
gh-97747: Improvements to WASM browser REPL. (#97665)
Improvements to WASM browser REPL.

Adds a text box to write and run code outside the REPL, a stop button, and handling of Ctrl-D for EOF.
2024-05-31 09:58:46 +02:00
Dino Viehland 0d07182821
gh-111201: Support pyrepl on Windows (#119559)
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-31 09:49:03 +02:00
Irit Katriel 13a5fdc72f
gh-119744: move a few functions from compile.c to flowgraph.c (#119745) 2024-05-30 21:55:06 +01:00
James De Bias 9732ed5ca9
gh-107262: Update Tkinter tests for Tcl/Tk 8.6.14 (GH-119322)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-30 20:34:59 +00:00
Serhiy Storchaka ef01e95ae3
gh-109218: Deprecate weird cases in the complex() constructor (GH-119620)
* Passing a string as the "real" keyword argument is now an error;
  it should only be passed as a single positional argument.
* Passing a complex number as the "real" or "imag" argument is now deprecated;
  it should only be passed as a single positional argument.
2024-05-30 23:30:57 +03:00
Hugo van Kemenade deda85717b
Docs: `shutil.rmtree`'s `onerror` has no pending removal version (#118947) 2024-05-30 14:26:46 -06:00
Serhiy Storchaka ec1ba26460
gh-109218: Improve documentation for the complex() constructor (GH-119687)
* Remove the equivalence with real+imag*1j which can be incorrect in corner
  cases (non-finite numbers, the sign of zeroes).
* Separately document the three roles of the constructor: parsing a string,
  converting a number, and constructing a complex from components.
* Document positional-only parameters of complex(), float(), int() and bool()
  as positional-only.
* Add examples for complex() and int().
* Specify the grammar of the string for complex().
* Improve the grammar of the string for float().
* Describe more explicitly the behavior when real and/or imag arguments are
  complex numbers. (This will be deprecated in future.)
2024-05-30 20:20:07 +00:00
Sam Gross 1c04c63ced
gh-119729: Use 't' in pkg-config file name for free-threaded build (#119738)
For example, the free-threaded build now generates
`lib/pkgconfig/python-3.13t.pc` and the debug build generates
`lib/pkgconfig/python-3.13d.pc`.
2024-05-30 13:48:28 -04:00
Serhiy Storchaka bf098d4157
gh-109218: Refactor tests for the complex() constructor (GH-119635)
* Share common classes.
* Use exactly representable floats and exact tests.
* Check the sign of zero components.
* Remove duplicated tests (mostly left after merging int and long).
* Reorder tests in more consistent way.
* Test more error messages.
* Add tests for missed cases.
2024-05-30 17:35:59 +00:00
Serhiy Storchaka e875c2d752
gh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792)
PhotoImage.get() retruns a string instead of a 3-tuple of integers
in this case.
2024-05-30 17:22:52 +00:00
Irit Katriel e91fc11faf
gh-119786: create folder in cpython repo for internals documentation (#119787) 2024-05-30 16:38:37 +00:00
Awbert 6fb191be15
gh-119779: Fix pyporting howto docs (#119785) 2024-05-30 18:51:22 +03:00
Ethan Smith e50fac96e8
gh-119336: Restore removed _PyLong_NumBits() function (#119418)
It is used by the pywin32 project.
2024-05-30 14:48:18 +00:00
Bradley Reynolds b1374aa1c2
gh-110383: Remove references to removed popen[234] (GH-112783)
Signed-off-by: Bradley Reynolds <bradley.reynolds@darbia.dev>
2024-05-30 12:21:37 +00:00
Lincoln db009348b4
gh-118055: Update the finder glossary entry (GH-118278) 2024-05-30 08:51:23 +00:00
Petr Viktorin 48f21b3631
gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay there (GH-119731)
The Full Grammar specification in the docs omits rule actions, so grammar rules that raise a syntax error looked like valid syntax.
This was solved in ef940de by hiding those rules in the custom syntax highlighter.

This moves all syntax-error alternatives to invalid rules, adds a validator that ensures that actions containing RAISE_SYNTAX_ERROR are in invalid rules, and reverts the syntax highlighter hack.
2024-05-30 09:27:32 +02:00
Barney Gale a5fef800d3
GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (#119766)
Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when
the `os.fwalk()` generator is finalized.
2024-05-30 03:45:47 +00:00
Barney Gale 3c890b503c
GH-89727: Fix `os.fwalk()` recursion error on deep trees (#119638)
Implement `os.fwalk()` using a list as a stack to avoid emitting recursion
errors on deeply nested trees.
2024-05-30 03:05:36 +00:00
Zachary Ware 2cc3502f98
subprocess docs: Fix semantically important typo (GH-119752)
GH-25416 accidentally replaced a reference to the *stderr* argument of
`subprocess.run` with a reference to the *stdin* argument.  *stdin* is
not affected by the `check_output` option.
2024-05-29 22:19:54 +00:00
Barney Gale 7ff61f51b6
GH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (#119573)
For silly reasons, pathlib's generic implementation of `walk()` currently
resides in `glob._Globber`. This commit moves it into
`pathlib._abc.PathBase.walk()` where it really belongs, and makes
`pathlib.Path.walk()` call `os.walk()`.
2024-05-29 20:51:04 +00:00
Barney Gale a150679f90
GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (#119634)
Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-29 20:11:30 +00:00
Sam Gross c22323cd1c
gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (#119527)
The deadlock only affected the free-threaded build and only occurred
when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call
might temporarily release the GIL while holding the type seqlock.
Another thread may spin trying to acquire the seqlock while holding the
GIL.

The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py`
from `test_multiprocessing_pool_circular_import`.
2024-05-29 15:26:04 -04:00
Steve Dower df93f5d4bf
gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426) 2024-05-29 18:51:13 +01:00