Commit Graph

121496 Commits

Author SHA1 Message Date
Nice Zombies cae4cdd07d
gh-117349: Micro-optimize a few `os.path` functions (#117350)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2024-04-02 21:32:35 +01:00
Guido van Rossum 8eda146e87
Fix successor opcode name printing in Tier 2 DEOPT debug message (#117471) 2024-04-02 18:25:48 +00:00
Sam Gross 027fa2eccf
gh-112087: Make `list.extend(dict)` behave atomically (#117438)
Add a special case for `list.extend(dict)` and `list(dict)` so that those
patterns behave atomically with respect to modifications to the list or
dictionary.

This is required by multiprocessing, which assumes that
`list(_finalizer_registry)` is atomic.
2024-04-02 10:45:00 -04:00
Sam Gross 954d616b4c
gh-117440: Make `syslog` thread-safe in free-threaded builds (#117441)
Use critical sections to protect access to the syslog module.
2024-04-02 10:44:26 -04:00
Petr Viktorin e569f9132b
gh-117074: Update Traversable.joinpath docs to the 3.11+ protocol (GH-117113) 2024-04-02 16:08:16 +02:00
AN Long 52f5b7f9e0
gh-115538: Use pathlib to compare prefixes in test_venv (GH-117076) 2024-04-02 14:10:24 +01:00
Victor Stinner e3b6f287fc
gh-113317: Argument Clinic: Add libclinic.return_converters (#117451)
Move the following converter classes to libclinic.return_converters:

* CReturnConverter
* CReturnConverterAutoRegister
* Py_ssize_t_return_converter
* bool_return_converter
* double_return_converter
* float_return_converter
* int_return_converter
* long_return_converter
* size_t_return_converter
* unsigned_int_return_converter
* unsigned_long_return_converter

Move also the add_c_return_converter() function there.
2024-04-02 11:29:39 +00:00
Mark Shannon c32dc47aca
GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
Grigoriev Semyon c97d3af239
gh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444) 2024-04-02 11:42:58 +01:00
Irit Katriel 1d5479b236
gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412) 2024-04-02 10:34:49 +00:00
Victor Stinner 5fd1897ec5
gh-113317: Argument Clinic: Add libclinic.converters module (#117315)
Move the following converter classes to libclinic.converters:

* PyByteArrayObject_converter
* PyBytesObject_converter
* Py_UNICODE_converter
* Py_buffer_converter
* Py_complex_converter
* Py_ssize_t_converter
* bool_converter
* byte_converter
* char_converter
* defining_class_converter
* double_converter
* fildes_converter
* float_converter
* int_converter
* long_converter
* long_long_converter
* object_converter
* self_converter
* short_converter
* size_t_converter
* slice_index_converter
* str_converter
* unicode_converter
* unsigned_char_converter
* unsigned_int_converter
* unsigned_long_converter
* unsigned_long_long_converter
* unsigned_short_converter

Move also the following classes to libclinic.converters:

* buffer
* robuffer
* rwbuffer

Move the following functions to libclinic.converters:

* correct_name_for_self()
* r()
* str_converter_key()

Move Null and NULL to libclinic.utils.
2024-04-02 10:09:53 +00:00
Moshe Kaplan 9dae05ee59
Docs: specify XML document name in xml.etree.elementtree example (#24223) 2024-04-01 19:53:00 +00:00
Matthew Davis fc2071687b
Docs: add more links to PIPE in subprocess docs (#25416) 2024-04-01 21:49:14 +02:00
Barney Gale fc8007ee36
GH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)
These undocumented functions are no longer used by `msilib`, so there's no
reason to keep them around.
2024-04-01 19:37:41 +00:00
Justin Turner Arthur c741ad3537
gh-77714: Provide an async iterator version of as_completed (GH-22491)
* as_completed returns object that is both iterator and async iterator
* Existing tests adjusted to test both the old and new style
* New test to ensure iterator can be resumed
* New test to ensure async iterator yields any passed-in Futures as-is

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2024-04-01 20:07:29 +03:00
Guido van Rossum ddf814db74
Silence compiler warnings in gc.c (#117422) 2024-04-01 16:13:38 +00:00
Petr Viktorin 179869af92
gh-94808: Fix refcounting in PyObject_Print tests (GH-117421) 2024-04-01 17:01:22 +02:00
neonene dd44ab994b
gh-117142: ctypes: Unify meta tp slot functions (GH-117143)
Integrates the following ctypes meta tp slot functions:
* `CDataType_traverse()` into `CType_Type_traverse()`.
* `CDataType_clear()` into `CType_Type_clear()`.
* `CDataType_dealloc()` into `CType_Type_dealloc()`.
* `CDataType_repeat()` into `CType_Type_repeat()`.
2024-04-01 15:28:14 +02:00
Steve (Gadget) Barnes 3de09cadde
gh-91565: Replace bugs.python.org links with Devguide/GitHub ones (GH-91568)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2024-04-01 13:02:07 +00:00
MonadChains 90c3c68a65
gh-94808:Improve coverage of PyObject_Print (GH-98749) 2024-04-01 12:52:25 +00:00
dependabot[bot] 348cf6e007
Bump mypy from 1.8.0 to 1.9.0 in /Tools (#117418)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-01 11:14:37 +00:00
dependabot[bot] 9b403fb559
build(deps-dev): bump types-psutil from 5.9.5.20240205 to 5.9.5.20240316 in /Tools (#117417)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-04-01 11:05:14 +00:00
dependabot[bot] 93c7d9d17b
build(deps-dev): bump types-setuptools from 69.1.0.20240301 to 69.2.0.20240317 in /Tools (#117419)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-01 11:38:38 +01:00
dependabot[bot] 3bb12e407c
build(deps): bump actions/add-to-project from 0.6.0 to 1.0.0 (#117415)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-01 09:54:33 +00:00
Adorilson Bezerra 56e99307c4
Doc: printf-style library/stdtype improvements (#16741) 2024-03-31 22:34:54 +00:00
Raymond Hettinger 18e12641a6
gh-117387 Remove hash mark from introductory text (#117409) 2024-03-31 16:09:22 -05:00
Deborah a32d693948
gh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)
This just documents the parameter that already exists.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-03-31 20:11:48 +00:00
Shantanu 262445358e
Link to the Python type system specification (#117400) 2024-03-31 12:02:48 -07:00
Barney Gale 752e18389e
GH-114575: Rename `PurePath.pathmod` to `PurePath.parser` (#116513)
And rename the private base class from `PathModuleBase` to `ParserBase`.
2024-03-31 19:14:48 +01:00
Sam Gross bfc57d43d8
gh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)
This fixes a crash in `test_threading.test_reinit_tls_after_fork()` when
running with the GIL disabled. We already properly handle the case where
the thread state is `_Py_THREAD_ATTACHED` in `tstate_delete_common()` --
we just need to remove an assertion.

Keeping the thread attached means that a stop-the-world pause, such as
for a `fork()`, won't commence until we remove our thread state from the
interpreter's linked list. This prevents a crash when the child process
tries to clean up the dead thread states.
2024-03-29 18:58:08 -04:00
Erlend E. Aasland 05e0b67a43
gh-116664: In _warnings.c, make filters_version access thread-safe (#117374)
- assert that the lock is held in already_warned()
- protect 'filters_version' increment in warnings_filters_mutated_impl()
2024-03-29 21:23:28 +01:00
Jason R. Coombs 019143fecb
gh-117348: Refactored RawConfigParser._read for similicity and comprehensibility (#117372)
* Extract method for _read_inner, reducing complexity and indentation by 1.

* Extract method for _raise_all and yield ParseErrors from _read_inner.

Reduces complexity by 1 and reduces touch points for handling errors in _read_inner.

* Prefer iterators to splat expansion and literal indexing.

* Extract method for _strip_comments. Reduces complexity by 7.

* Model the file lines in a class to encapsulate the comment status and cleaned value.

* Encapsulate the read state as a dataclass

* Extract _handle_continuation_line and _handle_rest methods. Reduces complexity by 8.

* Reindent

* At least for now, collect errors in the ReadState

* Check for missing section header separately.

* Extract methods for _handle_header and _handle_option. Reduces complexity by 6.

* Remove unreachable code. Reduces complexity by 4.

* Remove unreachable branch

* Handle error condition early. Reduces complexity by 1.

* Add blurb

* Move _raise_all to ParsingError, as its behavior is most closely related to the exception class and not the reader.

* Split _strip* into separate methods.

* Refactor _strip_full to compute the strip just once and use 'not any' to determine the factor.

* Replace use of 'sys.maxsize' with direct computation of the stripped value.

* Extract has_comments as a dynamic property.

* Implement clean as a cached property.

* Model comment prefixes in the RawConfigParser within a prefixes namespace.

* Use a regular expression to search for the first match.

Avoids mutating variables and tricky logic and over-computing all of the starts when only the first is relevant.
2024-03-29 16:06:09 -04:00
Sam Gross 01bd74eadb
gh-117300: Use stop the world to make `sys._current_frames` and `sys._current_exceptions` thread-safe. (#117301)
This adds a stop the world pause to make the two functions thread-safe
when the GIL is disabled in the free-threaded build.

Additionally, the main test thread may call `sys._current_exceptions()` as
soon as `g_raised.set()` is called. The background thread may not yet reach
the `leave_g.wait()` line.
2024-03-29 15:33:06 -04:00
Guido van Rossum 94c97423a9
Fix broken format in error for bad input in summarize_stats.py (#117375)
When you pass the script a non-existent input file, you get a TypeError instead of the intended ValueError.
2024-03-29 18:31:09 +00:00
mpage 5d21d884b6
gh-111926: Avoid locking in PyType_IsSubtype (#117275)
Read the MRO in a thread-unsafe way in `PyType_IsSubtype` to avoid locking. Fixing this is tracked in #117306. 

The motivation for this change is in support of making weakrefs thread-safe in free-threaded builds:

`WeakValueDictionary` uses a special dictionary function, `_PyDict_DelItemIf`
to remove dead weakrefs from the dictionary. `_PyDict_DelItemIf` removes a key
if a user supplied predicate evaluates to true for the value associated with
the key. Crucially for the `WeakValueDictionary` use case, the predicate
evaluation + deletion sequence is atomic, provided that the predicate doesn’t
suspend. The predicate used by `WeakValueDictionary` includes a subtype check,
which we must ensure doesn't suspend in free-threaded builds.
2024-03-29 13:42:02 -04:00
Sam Gross 19c1dd60c5
gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)
Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.
2024-03-29 13:35:43 -04:00
Sam Gross 397d88db5e
gh-117344: Skip flaky tests in free-threaded build (#117355)
The tests are not reliable with the GIL disabled. In theory, they can
fail with the GIL enabled too, but the failures are much more likely
with the GIL disabled.
2024-03-29 13:34:04 -04:00
Sam Gross f05fb2e65c
gh-112529: Don't untrack tuples or dicts with zero refcount (#117370)
The free-threaded GC sometimes sees objects with zero refcount. This can
happen due to the delay in merging biased reference counting fields,
and, in the future, due to deferred reference counting. We should not
untrack these objects or they will never be collected.

This fixes the refleaks in the free-threaded build.
2024-03-29 13:33:04 -04:00
Erlend E. Aasland ddf95b5f16
gh-116664: Fix unused var warnings in _warnings.c in non-free-threaded builds (#117373)
The warnings were introduced by commit c1712ef06.
2024-03-29 17:26:06 +00:00
Tian Gao 0fa571dbcd
Refactor pdb executable targets (#112570)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-03-29 12:02:01 -04:00
Pedro Lacerda 54f7e14500
gh-66449: configparser: Add support for unnamed sections (#117273)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-03-29 15:05:00 +00:00
Nikita Sobolev d9cfe7e565
gh-117166: Ignore empty and temporary dirs in `test_makefile` (#117190) 2024-03-29 14:14:25 +03:00
Victor Stinner 35b6c4a4da
gh-117347: Fix test_clinic side effects (#117363)
Save/restore converters in ClinicWholeFileTest and
ClinicExternalTest.
2024-03-29 10:25:17 +00:00
neonene 7e2fef8658
gh-117142: ctypes: Migrate global vars to module state (GH-117189) 2024-03-29 10:40:48 +01:00
Gregory P. Smith 2e9be80c99
Fix reversed assertRegex checks in test_ssl. (#117351) 2024-03-28 17:58:37 -07:00
傅立业(Chris Fu) 8eec7ed714
gh-117110: Fix subclasses of typing.Any with custom constructors (#117111) 2024-03-29 00:19:20 +00:00
Christopher Chianelli a17f313e39
gh-117339: Use NULL instead of None for LOAD_SUPER_ATTR in dis docs (GH-117343) 2024-03-29 06:26:56 +08:00
Michael Droettboom 26d328b2ba
GH-117121: Add pystats to JIT builds (GH-117346) 2024-03-28 15:23:08 -07:00
Nice Zombies 14f1ca7d53
gh-117335: Handle non-iterables for `ntpath.commonpath` (GH-117336) 2024-03-28 21:20:08 +00:00
Brandt Bucher 18cf239e39
Increase the JIT CI timeouts to 75 minutes (GH-117342) 2024-03-28 21:02:34 +00:00