Commit Graph

53443 Commits

Author SHA1 Message Date
Emily Morehouse c1600c78e4
gh-123856: Fix PyREPL failure when a keyboard interrupt is triggered after using a history search (#124396)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-25 20:22:03 +02:00
Tian Gao 28efeefab7
gh-123756: Disable restart command if pdb is in inline mode (#123757) 2024-09-25 11:18:01 -07:00
Irit Katriel 78aeb38f7d
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression (#124394) 2024-09-25 15:51:25 +01:00
Malcolm Smith 461c12b438
gh-116622: Make test_unzip_zipfile recognize Android error message format (#124462)
Make test_unzip_zipfile recognize Android error message format
2024-09-25 07:02:18 -07:00
Eric V. Smith 5c6e3b7150
gh-90562: Support zero argument super with dataclasses when slots=True (gh-124455)
Co-authored-by: @wookie184
Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-09-24 21:26:26 -04:00
Jelle Zijlstra 950fab46ad
dataclasses: Avoid using private class (#124465)
typing.get_origin() does what we need here, without reaching into
typing internals. This shouldn't change any behavior (so I am going
to skip news), but it sets a good example for other users introspecting
typing objects.
2024-09-24 14:02:18 -07:00
Victor Stinner 5a60566074
gh-124402: Require cpu resource in test_super slow method (#124434)
test___class___modification_multithreaded() now requires the 'cpu'
test resource on a Free Threaded build.
2024-09-24 22:36:45 +02:00
Jakub Kulík b169cf394f
gh-86009: Fix solaris detection in `_USE_CP_SENDFILE` check (GH-124289) 2024-09-24 22:23:17 +02:00
Jérémie Detrey d3c76dff44
bpo-44864: Do not translate user-provided strings in ArgumentParser.add_subparsers() (GH-27667)
Call _() on literal strings only.
2024-09-24 19:54:50 +00:00
Tian Gao af8403a58d
gh-120254: Add a `commands` argument to `pdb.set_trace` (#120255) 2024-09-24 12:52:15 -07:00
sobolevn 17b3bc9cc7
gh-124405: Fix `NameError` in `openpty` (#124406) 2024-09-24 20:06:39 +02:00
Victor Stinner 38a5beb12a
gh-124402: Require cpu resource in test_free_threading (#124438)
Require the 'cpu' test resource on slow test_free_threading tests.
2024-09-24 16:33:27 +02:00
Payton d21b0b5d36
gh-113008: Correct argparse usage output for required, mutually exclusive groups (GH-113085) 2024-09-24 17:14:35 +03:00
Serhiy Storchaka 4a5e4aade4
gh-59317: Improve parsing optional positional arguments in argparse (GH-124303)
Fix parsing positional argument with nargs equal to '?' or '*' if it is
preceded by an option and another positional argument.
2024-09-24 15:46:41 +03:00
Serhiy Storchaka e2f710792b
gh-124188: Fix PyErr_ProgramTextObject() (GH-124189)
* Detect source file encoding.
* Use the "replace" error handler even for UTF-8 (default) encoding.
* Remove the BOM.
* Fix detection of too long lines if they contain NUL.
* Return the head rather than the tail for truncated long lines.
2024-09-24 11:01:37 +03:00
Serhiy Storchaka 3c83f9958c
gh-72795: Make positional arguments with nargs='*' or REMAINDER non-required (GH-124306)
This allows to use positional argument with nargs='*' and without default
in mutually exclusive group and improves error message about required
arguments.
2024-09-24 07:55:33 +00:00
Serhiy Storchaka c578271366
gh-53780: Ignore the first "--" (double dash) between an option and command in argparse (GH-124275) 2024-09-24 07:35:28 +00:00
Serhiy Storchaka 3094cd17b0
gh-63143: Fix parsing mutually exclusive arguments in argparse (GH-124307)
Arguments with the value identical to the default value (e.g. booleans,
small integers, empty or 1-character strings) are no longer considered
"not present".
2024-09-24 10:23:07 +03:00
Victor Stinner 9d344fafc4
gh-124127: Make Py_REFCNT() opaque in limited C API 3.14 (#124128) 2024-09-24 08:42:58 +02:00
Serhiy Storchaka b82f07653e
gh-124130: Increase test coverage for \b and \B in regular expressions (GH-124330) 2024-09-24 06:31:10 +00:00
Jason Fried d87482bc4e
gh-119333: Add C api to have contextvar enter/exit callbacks (#119335)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-09-23 20:40:17 -07:00
Donghee Na ad7c778546
gh-123990: Good bye WITH_FREELISTS macro (gh-124358) 2024-09-24 01:28:59 +00:00
Petr Viktorin be76e3f26e
gh-100980: ctypes: Test, document, and fix finalizing _fields_ (GH-124292)
- If setting `_fields_` fails, e.g. with AttributeError, don't set the attribute in `__dict__`
- Document the “finalization” behaviour
- Beef up tests: add `getattr`, test Union as well as Structure
- Put common functionality in a common function

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-09-24 02:40:53 +02:00
Bénédikt Tran 38a887dc3e
gh-119004: fix a crash in equality testing between `OrderedDict` (#121329) 2024-09-23 18:44:36 -05:00
Alex Waygood 8a2baedc4b
Bump Ruff to 0.6.7 (#124384) 2024-09-23 22:19:35 +00:00
Savannah Ostrowski 7ee9921734
GH-87041: Fix incorrect indentation in argparse help (GH-124230)
In case of usage a long command along with max_help_position more than
the length of the command, the command's help was incorrectly started
on the new line.

Co-authored-by: Pavel Ditenbir <pavel.ditenbir@gmail.com>
2024-09-23 19:45:36 +00:00
Jelle Zijlstra 2e0d445364
gh-119180: Fix annotationlib.ForwardRef.evaluate with no globals (#124326)
We were sometimes passing None as the globals argument to eval(), which makes it
inherit the globals from the calling scope. Instead, ensure that globals is always
non-None. The test was passing accidentally because I passed "annotationlib" as a
module object; fix that. Also document the parameters to ForwardRef() and remove
two unused private ones.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-09-23 19:06:19 +00:00
Savannah Ostrowski dc48312717
GH-124321: Fix argparse negative number parsing to capture -.5(GH-124322)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-09-23 11:16:55 -07:00
Terry Jan Reedy d5f95ec07b
gh-112938: IDLE - Fix uninteruptable hang when Shell gets rapid continuous output. (#124310)
https://github.com/python/cpython/issues/88496 replaced text.update with text.update_idletasks in colorizer.py and outwin.py to fix test failures on macOS.  While theoretically correct, the result was Shell freezing when receiving continuous short strings to print.  Test: `while 1: 1`.

The guess is that there is no idle time in which to do the screen update.  Reverting the change in one of the files,
outwin, fixes the issue.  Colorizer runs ever 1/20 second and seems to work fine.

When running test-outwin on macOS, alias 'update'
to 'update_idletasks on the text used for testing.
2024-09-22 15:51:09 -04:00
Michał Górny 342e654b8e
gh-124213: Skip tests failing inside systemd-nspawn --suppress-sync=true (#124215)
Add a helper function that checks whether the test suite is running
inside a systemd-nspawn container, and skip the few tests failing
with `--suppress-sync=true` in that case.  The tests are failing because
`--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()`
calls, and therefore they always return success without checking for
invalid arguments.

Call `os.open(__file__, os.O_RDONLY | os.O_SYNC)` and check the errno to
detect whether `--suppress-sync=true` is actually used, and skip
the tests only in that scenario.
2024-09-20 13:37:49 +00:00
Y5 db6eb3640a
gh-124217, ipaddress: Add RFC 9637 reserved IPv6 block `3fff::/20` (#124240)
Signed-off-by: y5c4l3 <y5c4l3@proton.me>
2024-09-20 11:01:28 +00:00
Brian Schubert 63f196090f
gh-124248: Fix crash in struct when processing 0p fields (#124251) 2024-09-20 12:08:59 +02:00
Serhiy Storchaka baa3550bc3
gh-95468: Add more tests for "--" (double dash) in test_argparse (GH-124274) 2024-09-20 09:54:20 +00:00
Petr Viktorin aee219f455
gh-123880: Allow recursive import of single-phase-init modules (GH-123950)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2024-09-20 10:27:34 +02:00
sobolevn 3e36e5aef1
gh-123797: Check for runtime availability of `ptsname_r` on macos (#123806) 2024-09-20 09:30:27 +03:00
Serhiy Storchaka aae126748f
gh-81691: Fix handling of multiple "--" (double dashes) in argparse (GH-124233)
Only the first one has now been removed, all subsequent ones are now
taken literally.
2024-09-20 09:20:47 +03:00
Victor Stinner 7a2d77c903
test_cext, test_cppext: enable /W4 warnings on Windows (#124253)
Add an explicit cast to (void*) and add Py_UNUSED() to fix some
warnings in extension.c.
2024-09-19 22:32:01 +02:00
Serhiy Storchaka 992e8f6102
gh-124245: Fix UserWarning in test_argparse (GH-124246) 2024-09-19 21:35:12 +03:00
Jakub Kulík 8f82d9aa21
bpo-41843: Reenable use of sendfile in shutil module on Solaris (GH-23893) 2024-09-19 14:47:05 +00:00
Stefano Rivera 426569eb8c
Support the "pager" binary in _pyrepl (#122878)
Debian (and derivatives) provide a /usr/bin/pager binary, managed by the
alternatives system, that always points to an available pager utility.
Allow _pyrepl to use it, to follow system policy.

This is a very trivial change, from a patch that Debian has been
carrying since 2.7 era. Seems appropriate to upstream.
https://bugs.debian.org/799555
2024-09-19 13:18:24 +00:00
Sergey B Kirpichev 4420cf4dc9
gh-124040: Adjust few tests in testHypot/testDist to get exactly computed results (GH-124042) 2024-09-19 11:11:03 +03:00
sobolevn 7628f67d55
gh-123934: Fix `MagicMock` not to reset magic method return values (#124038) 2024-09-19 10:55:47 +03:00
Jacek ea7fe1fe2e
gh-124212: Fix undefined variable in error message in venv (GH-124211) 2024-09-18 22:05:18 +00:00
Furkan Onder 36682c0914
gh-124083: Skip test_signal.test_strsignal() on NetBSD (#124084)
Skip test_strsignal() on NetBSD due to TypeError.
2024-09-18 21:22:00 +00:00
Tomas R 21d2a9ab2f
gh-116022: Improve `repr()` of AST nodes (#117046)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-18 10:28:22 -07:00
Bénédikt Tran 5cd50cb6eb
gh-122145: Handle an empty AST body when reporting tracebacks (#122161) 2024-09-18 18:42:33 +02:00
Cody Maloney 8b6c7c7877
gh-120754: Refactor I/O modules to stash whole stat result rather than individual members (#123412)
Multiple places in the I/O stack optimize common cases by using the
information from stat. Currently individual members are extracted from
the stat and stored into the fileio struct. Refactor the code to store
the whole stat struct instead.

Parallels the changes to _io. The `stat` Python object doesn't allow
changing members, so rather than modifying estimated_size, just clear
the value.
2024-09-18 17:47:57 +02:00
Jelle Zijlstra 96f619faa7
gh-124206: Fix calling get_annotate_function() on static types (#124208)
Fixes #124206. No news entry because the bug this fixes was never
released.
2024-09-18 08:39:22 -07:00
Sam James 0c4884d8aa
test: fix _is_perf_version_at_least typo (#124199) 2024-09-18 13:44:32 +01:00
Petr Viktorin 42c8b0556c
gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-09-18 14:14:34 +02:00
Sergey B Kirpichev 8a284e1896
gh-119771: Set errno on overflows in _Py_c_pow() (#120256)
Before we did this in complex_pow() and behavior of the public C API
function _Py_c_pow() was different from the pure-python pow().
2024-09-18 10:39:11 +02:00
neonene 646f16bdee
gh-124153: Implement `PyType_GetBaseByToken()` and `Py_tp_token` slot (GH-124163) 2024-09-18 09:18:19 +02:00
Jacek a15a584bf3
gh-122765: make prompt in activate.csh robust against unbalanced quotes and newlines (GH-123751) 2024-09-17 17:16:43 +00:00
Sergey B Kirpichev 28aea5d07d
gh-123836: Check zero signs in math_testcases.txt (#123854)
Just like cmath_testcases.txt. These tests require IEEE 754 anyway.

Correct zero sign for sqrt tests to match math.h convention.
2024-09-17 10:22:40 +02:00
Savannah Ostrowski 14e5bdceff
GH-123945: Update regex for parsing negative numbers that contain underscores (#123970)
---------

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-09-16 23:30:17 -07:00
Furkan Onder 10de3600a9
GH-124108: Skip test_locale.test_strcoll_with_diacritic() on NetBSD (#124110)
Skip test_strcoll_with_diacritic() and test_strxfrm_with_diacritic()
of test_locale on NetBSD due to lack of UTF-8 LC_COLLATE
support.
2024-09-16 23:00:36 +00:00
sobolevn 9dacf430c2
Remove unused `_allowed_types` from `typing.py` (#124090) 2024-09-14 16:14:45 +03:00
sobolevn 1de46136b9
Remove unused variable in `MagicMixin._mock_set_magics` (#124092) 2024-09-14 10:20:44 +00:00
Loïc Estève eadb9660ed
gh-122957: Fix test flakiness in asyncio test in free-thread build (#124039) 2024-09-13 11:13:30 -07:00
Furkan Onder 9f42b62db9
gh-124030: Skip test_tcsendbreak on NetBSD for ENOTTY error (GH-124031) 2024-09-13 19:27:54 +03:00
Wenzel Jakob 74330d992b
gh-100554: Add ``Py_tp_vectorcall`` slot to set ``PyTypeObject.tp_vectorcall`` using the ``PyType_FromSpec`` function family. (#123332) 2024-09-13 17:40:25 +02:00
Benjamin Peterson bb904e063d
closes gh-124016: update Unicode to 16.0.0 (#124017) 2024-09-13 07:47:04 -07:00
Irit Katriel a9594a34c6
gh-124022: Fix bug where class docstring is removed in interactive mode (#124023)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-13 14:06:06 +00:00
Sergey B Kirpichev b46c65ed2b
gh-123811: Test that round(Decimal) can return signed zero (GH-124007) 2024-09-13 15:49:13 +03:00
Petr Viktorin 432bf31327
gh-123909: PyType_From*: Disallow metaclasses with custom tp_new (GH-123947) 2024-09-13 13:18:49 +02:00
sobolevn d7e83398c1
gh-108303: Remove the non-test `Lib/test/reperf.py` (GH-114356) 2024-09-13 13:13:52 +02:00
Malcolm Smith f554883425
gh-116622: Mock the passage of time in Android logcat rate limit tests (#124015)
Mock the passage of time in Android logcat rate limit tests

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2024-09-13 04:58:11 +00:00
Yngve Mardal Moe 584cdf8d41
gh-123614: Add save function to turtle.py (#123617) 2024-09-12 21:36:17 -07:00
Miro Hrončok f4e5643df6
gh-124027: Support Del, PgUp, and PgDn on TERM=vt100 (#124028)
pyrepl: Support Del, PgUp, and PgDn on TERM=vt100

From Fedora's /etc/inputrc:

    "\e[5~": history-search-backward
    "\e[6~": history-search-forward
    "\e[3~": delete-char

Fixes https://github.com/python/cpython/issues/124027
2024-09-13 02:07:23 +01:00
Jason R. Coombs a53812df12
gh-123085: Fix issue in inferred caller when resources package has no source (#123102)
gh-123085: Fix issue in inferred caller when resources package has no source.

From importlib_resources 6.4.3 (python/importlib_resources#314).
2024-09-12 19:08:06 +00:00
Sam Gross b2afe2aae4
gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` (#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-12 12:37:06 -04:00
Mark Shannon 4ed7d1d6ac
GH-123996: Explicitly mark 'self_or_null' as an array of size 1 to ensure that it is kept in memory for calls (GH-124003) 2024-09-12 15:32:45 +01:00
Jason R. Coombs 3ea51fa2e3
gh-123994: Generate utf-16 file using little endian and BOM. (#123995) 2024-09-12 10:14:46 -04:00
Anders Kaseorg a362c41bc9
gh-123968: Fix lower bound for `python -m random --float` (#123971) 2024-09-12 16:54:18 +03:00
sobolevn ac918ccad7
gh-123935: Fix typo in `_get_slots` in `dataclasses.py` (#123941) 2024-09-12 10:29:06 +03:00
Malcolm Smith 43303e362e
gh-116622: Switch test_stress_delivery_simultaneous from SIGUSR1 to SIGUSR2 (#123981)
Use SIGUSR1 instead of SIGUSR2 to improve reliability of signal stress test on Android.
2024-09-12 13:52:07 +08:00
Jason R. Coombs ba687d9481
gh-121735: Fix module-adjacent references in zip files (#123037)
* gh-116608: Apply style and compatibility changes from importlib_metadata.

* gh-121735: Ensure module-adjacent resources are loadable from a zipfile.

* gh-121735: Allow all modules to be processed by the ZipReader.

* Add blurb

* Remove update-zips script, unneeded.

* Remove unnecessary references to removed static fixtures.

* Remove zipdata fixtures, unused.
2024-09-11 22:33:07 -04:00
Irit Katriel e07154fd1e
gh-123958: apply docstring removal optimization in ast_opt instead of codegen (#123959) 2024-09-11 17:02:28 +00:00
Irit Katriel 6e23c89fcd
gh-123942: add missing test for docstring-handling code in ast_opt.c (#123943) 2024-09-11 15:39:53 +01:00
Xie Yanbo e9eedf19c9
Fix invisible character typo (#123933)
Remove accidental addition of zero-width character (U+FEFF) reported by @jaraco:
- c3f4a6b524 (commitcomment-146456562)
2024-09-11 07:44:46 -04:00
Sergey B Kirpichev d2b9b6f919
gh-123811: test that round() can return signed zero (#123829) 2024-09-11 11:21:05 +02:00
Serhiy Storchaka a1dbf2ea69
gh-77894: Fix a crash when the GC breaks a loop containing a memoryview (GH-123898)
Now a memoryview object can only be cleared if there are no buffers
that refer it.
2024-09-11 12:05:46 +03:00
Tushar Sadhwani 3597642ed5
gh-122239: Add actual count in unbalanced unpacking error message when possible (#122244) 2024-09-10 16:07:30 +01:00
Jelle Zijlstra b52de7e02d
gh-123881: Add additional test coverage for PEP 695 edge cases (#123886) 2024-09-10 08:26:42 +01:00
Raymond Hettinger 2afba5ca6d
Small improvements to the itertools docs (GH-123885) 2024-09-09 20:57:49 -05:00
Serhiy Storchaka c0c2aa7644
gh-122213: Add notes for pickle serialization errors (GH-122214)
This allows to identify the source of the error.
2024-09-09 21:28:55 +03:00
Eric Snow d8f3c1e8f9
gh-117482: Simplify the Fix For Builtin Types Slot Wrappers (GH-122865)
In gh-121602, I applied a fix to a builtin types initialization bug.
That fix made sense in the context of some broader future changes,
but introduced a little bit of extra complexity. That fix has turned
out to be incomplete for some of the builtin types we haven't
been testing. I found that out while improving the tests.

A while back, @markshannon suggested a simpler fix that doesn't
have that problem, which I've already applied to 3.12 and 3.13.
I'm switching to that here. Given the potential long-term
benefits of the more complex (but still incomplete) approach,
I'll circle back to it in the future, particularly after I've improved
the tests so no corner cases slip through the cracks.

(This is effectively a "forward-port" of 716c677 from 3.13.)
2024-09-09 16:04:58 +02:00
algonell 9017b95ff2
Fix typos (#123775) 2024-09-09 14:58:26 +02:00
Furkan Onder df4f0cbfad
gh-123823: Fix test_posix for unsupported posix_fallocate on NetBSD (#123824)
Fix test_posix for unsupported posix_fallocate on NetBSD.
2024-09-09 14:14:23 +02:00
Serhiy Storchaka b2a8c38bb2
gh-122311: Improve and unify pickle errors (GH-122771)
* Raise PicklingError instead of UnicodeEncodeError, ValueError
  and AttributeError in both implementations.
* Chain the original exception to the pickle-specific one as __context__.
* Include the error message of ImportError and some AttributeError in
  the PicklingError error message.
* Unify error messages between Python and C implementations.
* Refer to documented __reduce__ and __newobj__ callables instead of
  internal methods (e.g. save_reduce()) or pickle opcodes (e.g. NEWOBJ).
* Include more details in error messages (what expected, what got).
* Avoid including a potentially long repr of an arbitrary object in
  error messages.
2024-09-09 15:04:51 +03:00
Adam Turner 93b61bc124
gh-123843: Remove broken links to the Zope DateTimeWiki (#123846)
Co-authored-by: Conrad Bhuiyan-Volkoff <hi@cbv.im>
2024-09-08 22:39:23 -04:00
Sergey B Kirpichev 8ef8354ef1
gh-121039: add Floats/ComplexesAreIdenticalMixin to test.support.testcase (GH-121071) 2024-09-08 16:01:54 +03:00
Seth Michael Larson 76a1c5d183
gh-122792: Make IPv4-mapped IPv6 address properties consistent with IPv4 (GH-122793)
Make IPv4-mapped IPv6 address properties consistent with IPv4.
2024-09-07 11:05:58 -07:00
Łukasz Langa 033510e11d
gh-120221: Support KeyboardInterrupt in asyncio REPL (#123795)
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(gh-123178).

This also fixes freezes with pasting and an active input hook.
2024-09-06 21:28:29 +02:00
Sam Gross 0c080d7c77
gh-123321: Make Parser/myreadline.c locking safe in free-threaded build (#123690)
Use a `PyMutex` to avoid the race in mutex initialization. Use relaxed
atomics to avoid the data race on reading `_PyOS_ReadlineTState` when
checking for re-entrant calls.
2024-09-06 15:07:08 -04:00
Nadeshiko Manju 8a46a2ec50
gh-117657: Fix file descriptor race in test_socket.py (#123697) 2024-09-06 15:00:28 -04:00
aorcajo e95984826e
gh-119310: Fix encoding when reading old history file (#121779)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-06 15:40:29 +02:00
Malcolm Smith eca3fe40c2
gh-123780: Make test_pkgutil clean up `spam` module (GH-123036) 2024-09-06 15:23:55 +02:00
Victor Stinner 8311b11800
gh-119034, REPL: Change page up/down keys to search in history (#123607)
Change <page up> and <page down> keys of the Python REPL to history
search forward/backward.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-06 13:15:00 +02:00
Arnon Yaari d683f49a7b
gh-111201: fix auto-indent in pyrepl for muliple pound comments (#123196) 2024-09-06 07:33:40 +00:00
Peter Bierma fe24b718d2
gh-123275: Add tests for `PYTHON_GIL=1` and `-Xgil=1` (gh-123754) 2024-09-06 01:15:30 +00:00
nkinnan b5aa271f86
gh-123476: Add support for TCP_QUICKACK socket setting to Windows (#123478)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2024-09-05 22:59:48 +02:00
sobolevn aa1339aaaa
gh-123240: Raise input audit events in the new REPL (#123274) 2024-09-05 17:17:24 +02:00
Petr Viktorin 16be8db6be
gh-123465: Allow Py_RELATIVE_OFFSET for __*offset__ members (GH-123474) 2024-09-05 14:14:05 +02:00
Petr Viktorin ce9f84a47b
gh-97588: Move ctypes struct/union layout logic to Python (GH-123352)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-05 11:20:07 +02:00
Bar Harel a4562fedad
gh-123321: Fix Parser/myreadline.c to prevent a segfault during a multi-threaded race (#123323) 2024-09-04 17:21:30 +02:00
Nice Zombies c530ce1e9d
gh-118710: Make IPv*Address.version & max_prefixlen available on the class (GH-120698) 2024-09-04 15:51:12 +02:00
Victor Stinner 0d6b6e34a2
gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668) 2024-09-04 11:41:57 +00:00
Victor Stinner b423ae6b08
gh-107954, PEP 741: Adjust Python initialization config (#123663)
Setting dev_mode to 1 in an isolated configuration now enables also
faulthandler.

Moreover, setting "module_search_paths" option with
PyInitConfig_SetStrList() now sets "module_search_paths_set" to 1.
2024-09-04 10:58:32 +00:00
Wulian 7bd964dbbe
gh-121423: Improve import time of `socket` (#121424)
Improve import time of `socket` by writing `socket.errorTab`
as a constant and lazy import modules.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-09-04 12:00:37 +02:00
Damien 91ff700de2
gh-122989: Replace duplicate “self.policy.linesep” with “linesep” (#123002)
`linesep` is already defined as `self.policy.linesep`.  It appears that previous refactor was not completed.
2024-09-04 02:30:25 -04:00
devdanzin 782217f28f
gh-123572: Fix key codes in VK_MAP in windows_console.py (#122692) 2024-09-03 13:01:21 +00:00
Sergey B Kirpichev 6822cb23c6
gh-121804: always show error location for SyntaxError's in basic repl (#123202) 2024-09-03 12:37:29 +00:00
Victor Stinner ef9d54703f
gh-107954, PEP 741: Add PyInitConfig C API (#123502)
Add Doc/c-api/config.rst documentation.
2024-09-03 12:33:49 +00:00
Yorik Hansen 9684f40b9f
gh-123430: Add dark mode support to pages generated by http.server (#123475)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-09-03 09:32:11 +03:00
Inada Naoki 13f61bf7f1
gh-121313: multiprocessing: simplify by increasing the connection buffer size to 64KiB (GH-123559)
Increases the multiprocessing connection buffer size from 8k to 64k for efficiency, without overallocating.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-09-02 20:32:38 -07:00
abstractee 1f4a49ea53
Fix typos in warnings, docstrings, comments and text files (#123597) 2024-09-03 02:20:40 +02:00
Victor Stinner 33b790978d
gh-107954, PEP 741: Add PyConfig_Get()/Set() functions (#123472)
Add PyConfig_Get(), PyConfig_GetInt(), PyConfig_Set() and
PyConfig_Names() functions to get and set the current runtime Python
configuration.

Add visibility and "sys spec" to config and preconfig specifications.

_PyConfig_AsDict() now converts PyConfig.xoptions as a dictionary.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-02 23:25:08 +02:00
Barney Gale 5002f17794
GH-119518: Stop interning strings in pathlib GH-123356)
Remove `sys.intern(str(x))` calls when normalizing a path in pathlib. This
speeds up `str(Path('foo/bar'))` by about 10%.
2024-09-02 18:14:09 +02:00
Bénédikt Tran 77a2fb4bf1
gh-123409: fix `IPv6Address.reverse_pointer` for IPv4-mapped addresses (GH-123419)
Fix functionality that was broken with better textual representation for IPv4-mapped addresses (gh-87799)
2024-09-02 17:05:05 +02:00
Donghee Na f95fc4de11
gh-101525: Skip test_gdb if the binary is relocated by BOLT. (gh-118572) 2024-09-02 13:24:53 +00:00
sobolevn 23f159ae71
gh-123562: Improve `SyntaxError` message for `case ... as a.b` (#123563) 2024-09-02 13:11:44 +02:00
Daniel Hollas 2304774465
gh-118761: Speedup pathlib import by deferring shutil (#123520)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-01 15:44:48 +01:00
Yoda 42a818912b
gh-123341: Support `tkinter.Event` type subcript (#123353)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-09-01 12:47:07 +01:00
sobolevn 75e72822a3
gh-91126: Docs and tests for slotted dataclasses with `__init_subclass__` (#123342) 2024-09-01 13:25:34 +03:00
Aarni Koskela 0b6acfee04
gh-123494: Improve documentation for ``webbrowser`` return types (#123495)
Document the return value for ``webbrowser.open*()``.
2024-09-01 06:17:03 +01:00
Luka 917283ada6
gh-115238: Remove a redundant f-string in graphlib (#115239) 2024-09-01 06:12:53 +01:00
Seth Michael Larson 34ddb64d08
gh-121285: Remove backtracking when parsing tarfile headers (GH-121286)
* Remove backtracking when parsing tarfile headers
* Rewrite PAX header parsing to be stricter
* Optimize parsing of GNU extended sparse headers v0.0

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-08-31 15:17:05 -07:00
Serhiy Storchaka 5414b97ce2
gh-123309: Remove check for redefined memo entry in pickletools.dis() (GH-123374)
Such pickles are supported by the Unpickler even if the Pickler does not
produce them.
2024-08-31 16:21:49 +03:00
Serhiy Storchaka fc897fcc01
gh-76960: Fix urljoin() and urldefrag() for URIs with empty components (GH-123273)
* urljoin() with relative reference "?" sets empty query and removes fragment.
* Preserve empty components (authority, params, query, fragment) in urljoin().
* Preserve empty components (authority, params, query) in urldefrag().

Also refactor the code and get rid of double _coerce_args() and
_coerce_result() calls in urljoin(), urldefrag(), urlparse() and
urlunparse().
2024-08-31 12:42:08 +03:00
Serhiy Storchaka e5a567b0a7
gh-123309: Add more tests for the pickletools module (GH-123355)
Add tests for genops() and dis().
2024-08-31 12:30:05 +03:00
Oded Arbel 10bf615bab
gh-108172: do not override OS preferred browser if it is a super-string of a known browser (GH-113011)
When checking if the registering browser is the "OS preferred browser", do not use a substring search - that makes no sense: one can have a preferred browser that looks like a super-string of a known browser, e.g. "firefox-nightly" vs "firefox".

https://github.com/python/cpython/issues/108172 explains in more detail, and lays out a potential better future enhancement for this case of just using xdg-open.  We'll go with this for now.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-08-30 23:11:57 -07:00
Alexander P. 74bfb53e3a
gh-121313: Limit the reading size from pipes to their default buffer size on POSIX systems (GH-121315)
See https://github.com/python/cpython/issues/121313 for analysis, but this greatly reduces memory overallocation and overhead when multiprocessing is sending non-small data over its pipes between processes.
2024-08-30 22:57:22 -07:00
sobolevn e451a8937d
gh-123440: Improve error message for `except as` used with not a name (#123442) 2024-08-30 17:21:59 +01:00
Victor Stinner d8e69b2c1b
gh-122854: Add Py_HashBuffer() function (#122855) 2024-08-30 15:42:27 +00:00
Victor Stinner 3d60dfbe17
gh-121645: Add PyBytes_Join() function (#121646)
* Replace _PyBytes_Join() with PyBytes_Join().
* Keep _PyBytes_Join() as an alias to PyBytes_Join().
2024-08-30 12:57:33 +00:00
sobolevn f8a736b8e1
gh-123446: Fix empty function names in `TypeError`s in `typeobject` (#123470) 2024-08-30 10:36:51 +03:00
Serhiy Storchaka 32c7dbb2bc
gh-121485: Always use 64-bit integers for integers bits count (GH-121486)
Use 64-bit integers instead of platform specific size_t or Py_ssize_t
to represent the number of bits in Python integer.
2024-08-30 08:13:24 +03:00
Serhiy Storchaka 0c3ea30238
gh-123431: Harmonize extension code checks in pickle (GH-123434)
This checks are redundant in normal circumstances and can only work if
the extension registry was intentionally broken.

* The Python implementation now raises exception for the extension code
  with false boolean value.
* Simplify the C code. RuntimeError is now raised in explicit checks.
* Add many tests.
2024-08-29 08:26:16 +03:00
Petr Viktorin b379f1b26c
gh-122136: test_asyncio: Don't fail if the kernel buffers more data than advertised (GH-123423) 2024-08-28 22:36:42 +02:00
Irit Katriel 61bef6245c
gh-123142: fix too wide source location of GET_ITER/GET_AITER (#123420) 2024-08-28 17:11:52 +01:00
Bogdan Romanyuk be083cee34
gh-123344: Add missing ast optimizations for PEP 696 (#123377)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-08-28 06:38:56 -07:00
Victor Stinner 4c6dca8292
gh-120389: Add PyLong_FromInt64() and PyLong_AsInt64() (#120390)
Add new functions to convert C <stdint.h> numbers from/to Python int:

* PyLong_FromInt32()
* PyLong_FromUInt32()
* PyLong_FromInt64()
* PyLong_FromUInt64()
* PyLong_AsInt32()
* PyLong_AsUInt32()
* PyLong_AsInt64()
* PyLong_AsUInt64()
2024-08-28 10:16:13 +00: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
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
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