Commit Graph

3785 Commits

Author SHA1 Message Date
Sam Gross cf6f23b0e3
gh-88402: Add new sysconfig variables on Windows (GH-110049)
Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
2023-10-04 22:50:29 +00:00
Xuehai Pan 3bbe3b7c82
gh-110222: Add support of PyStructSequence in copy.replace() (GH-110223) 2023-10-04 19:47:41 +03:00
Serhiy Storchaka 254e30c487
gh-109151: Enable readline in the sqlite3 CLI (GH-109152) 2023-10-04 14:16:44 +03:00
Serhiy Storchaka 5b9a3fd6a0
gh-110273: dataclasses.replace() now raise TypeError for all invalid arguments (GH-110274)
dataclasses.replace() now raises TypeError instead of ValueError if
specify keyword argument for a field declared with init=False or miss keyword
argument for required InitVar field.
2023-10-04 09:20:14 +03:00
Alex Waygood bfe7e72522
gh-109653: Defer importing `warnings` in several modules (#110286) 2023-10-04 06:09:43 +01:00
Guido van Rossum 6678ef41d2
Add --inline-caches flag to dis command line (#110249) 2023-10-03 00:49:34 +00:00
Alex Waygood 21a6263020
gh-109653: Reduce the import time of `random` by 60% (#110221) 2023-10-02 22:56:31 +00:00
Charles Machalow 29b875bb93
gh-109590: Update shutil.which on Windows to prefer a PATHEXT extension on executable files (GH-109995)
The default arguments for shutil.which() request an executable file, but extensionless files are not executable on Windows and should be ignored.
2023-10-02 09:27:30 +01:00
Barney Gale 15de493395
GH-107465: Add `pathlib.Path.from_uri()` classmethod. (#107640)
This method supports file URIs (including variants) as described in RFC 8089, such as URIs generated by `pathlib.Path.as_uri()` and `urllib.request.pathname2url()`.

The method is added to `Path` rather than `PurePath` because it uses `os.fsdecode()`, and so its results vary from system to system. I intend to deprecate `PurePath.as_uri()` and move it to `Path` for the same reason.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-10-01 16:14:02 +01:00
Raymond Hettinger 62405c7867
gh-110150: Fix base case handling in quantiles() (gh-110151) 2023-09-30 23:35:54 -05:00
Victor Stinner a46e960768
gh-109649: Use os.process_cpu_count() (#110165)
Replace os.cpu_count() with os.process_cpu_count() in modules:

* compileall
* concurrent.futures
* multiprocessing

Replace os.cpu_count() with os.process_cpu_count() in programs:

* _decimal deccheck.py test
* freeze.py
* multissltests.py
* python -m test (regrtest)
* wasm_build.py

Other changes:

* test.pythoninfo logs os.process_cpu_count().
* regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
2023-10-01 03:14:57 +02:00
Victor Stinner c81521020d
gh-109649: Add os.process_cpu_count() function (#109907)
* Refactor os_sched_getaffinity_impl(): move variable definitions to
  their first assignment.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!
* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
2023-10-01 00:12:51 +02:00
Barney Gale 89966a694b
GH-89812: Add `pathlib._PathBase` (#106337)
Add private `pathlib._PathBase` class. This will be used by an experimental PyPI package to incubate a `tarfile.TarPath` class.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-09-30 15:45:01 +01:00
Victor Stinner 6351842121
gh-109047: concurrent.futures catches PythonFinalizationError (#109810)
concurrent.futures: The *executor manager thread* now catches
exceptions when adding an item to the *call queue*. During Python
finalization, creating a new thread can now raise RuntimeError. Catch
the exception and call terminate_broken() in this case.

Add test_python_finalization_error() to test_concurrent_futures.

concurrent.futures._ExecutorManagerThread changes:

* terminate_broken() no longer calls shutdown_workers() since the
  call queue is no longer working anymore (read and write ends of
  the queue pipe are closed).
* terminate_broken() now terminates child processes, not only
  wait until they complete.
* _ExecutorManagerThread.terminate_broken() now holds shutdown_lock
  to prevent race conditons with ProcessPoolExecutor.submit().

multiprocessing.Queue changes:

* Add _terminate_broken() method.
* _start_thread() sets _thread to None on exception to prevent
  leaking "dangling threads" even if the thread was not started
  yet.
2023-09-29 19:31:19 +00:00
Furkan Onder 3439cb0049
gh-66143: Allow copying and pickling of CodecInfo object (GH-109235)
Co-authored-by: Robert Lehmann <mail@robertlehmann.de>
2023-09-29 20:07:09 +03:00
James Hilton-Balfe 7d57288f6d
gh-109495: Remove unused slots from the Python implementation of datetime (GH-109494) 2023-09-29 19:57:32 +03:00
Jelle Zijlstra 7dc2c5093e
gh-110045: Update symtable module for PEP 695 (#110066) 2023-09-29 02:08:04 +00:00
Victor Stinner bd4518c60c
gh-110036: multiprocessing Popen.terminate() catches PermissionError (#110037)
On Windows, multiprocessing Popen.terminate() now catchs
PermissionError and get the process exit code. If the process is
still running, raise again the PermissionError. Otherwise, the
process terminated as expected: store its exit code.
2023-09-29 02:41:12 +02:00
Davide Rizzo b14f0ab51c
gh-110038: KqueueSelector must count all read/write events (#110039) 2023-09-28 17:25:10 +00:00
Amin Alaee 7df8b16d28
gh-109782: Ensure `os.path.isdir` has the same signature on all platforms (GH-109790) 2023-09-28 16:17:30 +01:00
Nikita Sobolev f65f9e80fe
gh-109818: `reprlib.recursive_repr` copies `__type_params__` (#109819) 2023-09-27 19:26:42 -07:00
Dale Collison 74723e1110
gh-109461: Update logging module lock to use context manager (#109462)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-27 18:26:41 +02:00
Barney Gale ecd813f054
GH-109187: Improve symlink loop handling in `pathlib.Path.resolve()` (GH-109192)
Treat symlink loops like other errors: in strict mode, raise `OSError`, and
in non-strict mode, do not raise any exception.
2023-09-26 17:57:17 +01:00
Antoine Pitrou 0eb98837b6
gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (#109629)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-26 13:57:25 +02:00
Serhiy Storchaka 8ac2085b80
gh-109631: Allow interruption of short repeated regex matches (GH-109867)
Counting for signal checking now continues in new match from the point where
it ended in the previous match instead of starting from 0.
2023-09-26 10:56:33 +03:00
Jason R. Coombs e9791ba351
gh-88233: zipfile: refactor _strip_extra (#102084)
* Refactor zipfile._strip_extra to use higher level abstractions for extras instead of a heavy-state loop.

* Add blurb

* Remove _strip_extra and use _Extra.strip directly.

* Use memoryview to avoid unnecessary copies while splitting Extras.
2023-09-25 19:46:58 -04:00
Antoine Pitrou 88a6137cdb
gh-109599: Add types.CapsuleType (#109600)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-09-25 19:50:39 +02:00
Alex Waygood 40d1de7581
gh-109653: Avoid a top-level import of `types` in `functools` (#109804) 2023-09-24 17:18:27 +01:00
Alex Waygood 51863b7d6e
gh-109653: Improve `enum` import time by avoiding import of `functools` (GH-109789) 2023-09-23 11:31:17 -07:00
Alex Waygood e8be0c9c5a
gh-109653: `typing.py`: improve import time by creating soft-deprecated members on demand (#109651)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2023-09-23 08:46:35 +01:00
Hugo van Kemenade 8a82bff12c
Docs: Update Donghee Na's name (#109743) 2023-09-22 12:52:57 -06:00
Tian Gao 73ccfa28c5
gh-109164: Replace `getopt` with `argparse` in pdb (#109165)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-22 16:55:48 +00:00
elfstrom 405b06375a
gh-105829: Fix concurrent.futures.ProcessPoolExecutor deadlock (#108513)
This fixes issue #105829, https://github.com/python/cpython/issues/105829

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Co-authored-by: Chris Withers <chris@withers.org>
Co-authored-by: Thomas Moreau <thomas.moreau.2010@gmail.com>
2023-09-22 13:55:56 +01:00
EliseevEgor 8fc071345b
gh-106584: Fix exit code for unittest in Python 3.12 (#106588)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-09-22 14:26:27 +02:00
AN Long 869f177b5c
gh-74481: Add missing debug function docs and constants to msvcrt (GH-109650) 2023-09-21 16:44:24 +01:00
Victor Stinner d4cea794a7
gh-109613: _pystat_fromstructstat() checks for exceptions (#109618)
Fix os.stat() and os.DirEntry.stat(): check for exceptions.
Previously, on Python built in debug mode, these functions could
trigger a fatal Python error (and abort the process) when a function
succeeded with an exception set.

_pystat_fromstructstat() now exits immediately if an exception is
raised, rather only checking for exceptions at the end. It fix
following fatal error in fill_time():

    Fatal Python error: _Py_CheckSlotResult:
    Slot * of type int succeeded with an exception set
2023-09-21 09:55:06 +02:00
James Gerity def828995a
fixes gh-109559: Update `unicodedata` for Unicode 15.1.0 (GH-109560)
---------

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2023-09-19 22:07:47 -07:00
Jelle Zijlstra 1293fcc3c6
gh-109543: Remove unnecessary hasattr check (#109544)
Also added a new test case covering the scenario I thought this
might be about.
2023-09-19 20:15:52 -07:00
Mateusz Nowak 5a740cd06e
gh-109109: Expose retrieving certificate chains in SSL module (#109113)
Adds APIs to get the TLS certificate chains, verified or full unverified, from SSLSocket and SSLObject.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-09-20 01:20:54 +00:00
Ronan Pigott ddf2e953c2
gh-109033: Return filename with os.utime errors (#109034)
The filename was previously intentionally omitted from exception because
"it might confuse the user". Uncaught exceptions are not generally a
replacement for user-facing error messages, so obscuring this
information only has the effect of making the programmer's life more
difficult.
2023-09-20 01:18:23 +02:00
Shantanu 23f9f6f464
gh-108843: fix ast.unparse for f-string with many quotes (#108981) 2023-09-18 14:56:19 +01:00
Brett Cannon e218e5022e
GH-83417: Allow `venv` to add a `.gitignore` file to environments via a new `scm_ignore_file` parameter (GH-108125)
This feature is off by default via code but on by default via the CLI. The `.gitignore` file contains `*` which causes the entire directory to be ignored.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-15 22:38:08 +00:00
Gregory P. Smith 59073c9ab8
gh-109096: Deprecate `http.server.CGIHTTPRequestHandler` (#109387)
Deprecate `http.server.CGIHTTPRequestHandler`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-15 14:26:45 -07:00
buermarc 68a6f21f47
gh-109375: Fix bug where pdb registers an alias without an associated command (#109376) 2023-09-14 22:31:30 +01:00
Irit Katriel b303d3ad3e
gh-109319: deprecate dis.HAVE_ARGUMENT (#109320) 2023-09-12 16:45:35 +01:00
Nikita Sobolev 66d1d7eb06
gh-84867: Do not load tests from TestCase and FunctionTestCase (GH-100497) 2023-09-12 16:33:30 +03:00
Tian Gao 391f3e3ca9
GH-106734: Disable tab completion in pdb's multiline mode (GH-106735) 2023-09-11 18:28:43 -07:00
Victor Stinner 517cd82ea7
gh-108987: Fix _thread.start_new_thread() race condition (#109135)
Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().
2023-09-11 17:27:03 +02:00
Victor Stinner a9b1f84790
gh-107219: Fix concurrent.futures terminate_broken() (#109244)
Fix a race condition in concurrent.futures. When a process in the
process pool was terminated abruptly (while the future was running or
pending), close the connection write end. If the call queue is
blocked on sending bytes to a worker process, closing the connection
write end interrupts the send, so the queue can be closed.

Changes:

* _ExecutorManagerThread.terminate_broken() now closes
  call_queue._writer.
* multiprocessing PipeConnection.close() now interrupts
  WaitForMultipleObjects() in _send_bytes() by cancelling the
  overlapped operation.
2023-09-11 08:11:31 +00:00
Serhiy Storchaka d6892c2b92
gh-50644: Forbid pickling of codecs streams (GH-109180)
Attempts to pickle or create a shallow or deep copy of codecs streams
now raise a TypeError.

Previously, copying failed with a RecursionError, while pickling
produced wrong results that eventually caused unpickling to fail with
a RecursionError.
2023-09-10 20:06:09 +03:00
Serhiy Storchaka 92578919a6
gh-109174: Add support of SimpleNamespace in copy.replace() (GH-109175) 2023-09-10 08:09:25 +03:00
Ethan Furman c74e440168
gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)
add guard so that ``Enum('bar')`` raises a TypeError instead of
creating a new enum class called `bar`.  To create the new but
empty class, use:

    huh = Enum('bar', names=())
2023-09-07 18:19:03 -07:00
Serhiy Storchaka 6f3c138dfa
gh-108751: Add copy.replace() function (GH-108752)
It creates a modified copy of an object by calling the object's
__replace__() method.

It is a generalization of dataclasses.replace(), named tuple's _replace()
method and replace() methods in various classes, and supports all these
stdlib classes.
2023-09-06 23:55:42 +03:00
Anthony Shaw 2c4c26c4ce
gh-108469: Update ast.unparse for unescaped quote support from PEP701 [3.12] (#108553)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-09-05 21:01:23 +01:00
Tian Gao 6304d983a0
gh-108463: Make expressions/statements work as expected in pdb (#108464) 2023-09-04 21:44:40 +00:00
Victor Stinner 5a79d2ae57
Revert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)
This reverts commit 08447b5deb.

Revert also _ctypes.c changes of the PyDict_ContainsString() change,
commit 6726626646.
2023-09-04 11:21:47 +02:00
Barney Gale bdc3c884cd
GH-78722: Raise exceptions from `pathlib.Path.iterdir()` without delay. (#107320)
`pathlib.Path.iterdir()` now immediately raises any `OSError`
exception from `os.listdir()`, rather than waiting until its
result is iterated over.
2023-09-02 16:08:03 +01:00
Alex Waygood a1cbace91b
gh-105509: Simplify implementation of `typing.Annotated` (#105510) 2023-09-01 13:57:25 -07:00
Nikita Sobolev 044b8b3b6a
gh-107805: Fix signatures of module-level generated functions in `turtle` (#107807)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-01 01:18:15 -07:00
Ethan Furman d48760b2f1
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704)
When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .

    member = object.__new__(cls)
    member = int.__new__(cls, value)
    member = str.__new__(cls, value)

Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.
2023-08-31 12:45:12 -07:00
Erlend E. Aasland 2a3926fa51
gh-108590: Revert gh-108657 (commit 400a1cebc) (#108686)
Reverted per Serhiy's request.
2023-08-30 14:53:10 +00:00
Corvin 400a1cebc7
gh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (#108657)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-30 09:06:21 +00:00
Erlend E. Aasland 0b0c1d046c
gh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (#108632)
Deprecate passing the callback callable by keyword for the following
sqlite3.Connection APIs:

- set_authorizer(authorizer_callback)
- set_progress_handler(progress_handler, ...)
- set_trace_callback(trace_callback)

The affected parameters will become positional-only in Python 3.15.
2023-08-29 22:02:12 +02:00
Matthias Bussonnier f75cefd402
gh-106670: Allow Pdb to move between chained exceptions (#106676) 2023-08-28 18:31:03 +00:00
Erlend E. Aasland 4116592b6f
gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs (#108281)
Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following sqlite3.Connection APIs:

- create_function(name, nargs, callable, ...)
- create_aggregate(name, nargs, callable)

The affected parameters will become positional-only in Python 3.15.
2023-08-28 13:32:07 +00:00
Erlend E. Aasland 8db451ceb1
gh-64662: Fix NEWS entry and remove What's New entry (#108565) 2023-08-28 12:02:26 +00:00
Erlend E. Aasland d0160c7c22
gh-64662: Add virtual table support to sqlite3.Connection.iterdump (#108340)
Co-authored-by: Aviv Palivoda <palaviv@gmail.com>
2023-08-28 00:18:32 +02:00
Ori Avtalion a429eafef2
gh-108542: Fix incorrect module name in NEWS entry for gh-105475 (#108543) 2023-08-27 21:50:59 +02:00
Raymond Hettinger 042aa88bcc
gh-108322: Optimize statistics.NormalDist.samples() (gh-108324) 2023-08-27 08:59:40 -05:00
Jelle Zijlstra 482fad7f01
gh-108295: Fix crashes with TypeVar weakrefs (#108517) 2023-08-26 17:13:33 -07:00
Serhiy Storchaka 2b15536fa9
gh-107913: Fix possible losses of OSError error codes (GH-107930)
Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
2023-08-27 00:35:06 +03:00
denballakh e407cea193
gh-107406: Add better `struct.Struct` repr (#107407) 2023-08-26 15:24:16 +05:30
Corvin 24aa249a66
gh-107932: Fix dis module for bytecode that does not have an associated source line (GH-107988) 2023-08-25 09:31:26 +01:00
Peeyush Aggarwal 8d4052075e
gh-103384: Generalize the regex pattern `BaseConfigurator.INDEX_PATTERN` to allow spaces and non-alphanumeric characters in keys. (GH-103391)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-25 09:15:26 +01:00
Chris Markiewicz 2eb60c1934
gh-108111: Flush gzip write buffer before seeking, fixing bad writes (#108341)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-08-24 10:23:01 +02:00
Petr Viktorin 5d18715765
gh-107811: tarfile: treat overflow in UID/GID as failure to set it (#108369) 2023-08-23 20:00:07 +02:00
Serhiy Storchaka 154477be72
gh-50002: xml.dom.minidom now preserves whitespaces in attributes (GH-107947)
Also double quotes (") are now only quoted in attributes.
2023-08-23 15:23:41 +03:00
Petr Viktorin 31b61d19ab
gh-108294: Add time.sleep audit event (GH-108298) 2023-08-23 11:00:22 +02:00
Erlend E. Aasland 1a1bfc2891
gh-105539: Emit ResourceWarning if sqlite3 database is not closed explicitly (#108015) 2023-08-22 13:10:29 +02:00
Hugo van Kemenade 71962e5237
Run sphinx-lint on Misc/NEWS.d/next/ (#108212)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-21 13:13:55 +00:00
balmeida-nokia 37135d25e2
gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485)
In the stack call of: _init_read_gz()
```
_read, tarfile.py:548
read, tarfile.py:526
_init_read_gz, tarfile.py:491
```
a try;except exists that uses `self.exception`, so it needs to be set before
calling _init_read_gz().
2023-08-21 11:39:06 +00:00
Petr Viktorin acbd3f9c5c
gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Lumír 'Frenzy' Balhar <frenzy.madness@gmail.com>
2023-08-21 12:56:46 +02:00
Raymond Hettinger 20cc90c0df
gh-105736: Sync pure python version of OrderedDict with the C version (#108098) 2023-08-21 11:49:08 +02:00
Serhiy Storchaka 79db9d9a0e
gh-72684: Tkinter: provide interface for "tk busy" subcommands (GH-107684)
Add tkinter.Misc methods: tk_busy_hold(), tk_busy_configure(), tk_busy_cget(),
tk_busy_forget(), tk_busy_current(), and tk_busy_status().
2023-08-19 14:48:02 +03:00
Tyler Smart 9bb576cb07
gh-107995: Fix doctest collection of functools.cached_property objects (#107996)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-18 15:44:38 +00:00
Erlend E. Aasland fd19509220
gh-108083: Don't ignore exceptions in sqlite3.Connection.__init__() and .close() (#108084)
- Add explanatory comments
- Add return value to connection_close() for propagating errors
- Always check the return value of connection_exec_stmt()
- Assert pre/post state in remove_callbacks()
- Don't log unraisable exceptions in case of interpreter shutdown
- Make sure we're not initialized if reinit fails
- Try to close the database even if ROLLBACK fails

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-18 11:39:12 +00:00
Nikita Sobolev 80f30cf51b
gh-102029: Deprecate passing arguments to `_PyRLock` in `threading` (#102071) 2023-08-17 09:19:07 -07:00
Serhiy Storchaka 882cb79afa
gh-56166: Deprecate passing confusing positional arguments in re functions (#107778)
Deprecate passing optional arguments maxsplit, count and flags in
module-level functions re.split(), re.sub() and re.subn() as positional.
They should only be passed by keyword.
2023-08-16 13:35:35 -07:00
SKO abd9cc52d9
gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612)
Restore the global Input Stream pointer after trying to match a sub-pattern.

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
2023-08-16 10:43:45 +03:00
6t8k a86df298df
gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802)
Restore following CPython <= 3.10.5 behavior of shutil.make_archive()
that went away as part of gh-93160:

Do not create an empty archive if root_dir is not a directory, and, in
that case, raise FileNotFoundError or NotADirectoryError regardless
of format choice. Beyond the brought-back behavior, the function may
now also raise these exceptions in dry_run mode.
2023-08-16 10:00:03 +03:00
Finn Womack 0932272431
gh-106242: Fix path truncation in os.path.normpath (GH-106816) 2023-08-15 16:33:00 +01:00
Dong-hee Na 6515ec3d3d
gh-107963: Fix set_forkserver_preload to check the type of given list (#107965)
gh-107963: Fix set_forkserver_preload to check the type of given list
2023-08-15 15:58:12 +02:00
Erlend E. Aasland 13c36dc9ae
gh-93057: Deprecate positional use of optional sqlite3.connect() params (#107948) 2023-08-15 08:09:56 +00:00
Romuald Brunet a482e5bf00
gh-76913: Add "merge extras" feature to LoggerAdapter (GH-107292) 2023-08-15 08:23:54 +01:00
Nikita Sobolev d93b4ac2ff
gh-101162: Forbid using issubclass() with GenericAlias as the 1st arg (GH-103369) 2023-08-11 22:12:11 +03:00
Serhiy Storchaka a39f0a3506
gh-107782: Pydoc: fall back to __text_signature__ if inspect.signature() fails (GH-107786)
It allows to show signatures which are not representable in Python,
e.g. for getattr and dict.pop.
2023-08-11 20:51:36 +03:00
Andrew Geng 5f7d4ecf30
gh-106558: break ref cycles through exceptions in multiprocessing manager (#106559) 2023-08-11 17:44:18 +00:00
denballakh 4845b9712f
gh-107409: set `__wrapped__` attribute in `reprlib.recursive_repr` (#107410)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-08-10 06:55:49 +00:00
Mina Galić f50c17243a
GH-107812: extend `socket`'s netlink support to FreeBSD (gh-107813) 2023-08-10 00:47:46 +00:00
Serhiy Storchaka 7b6e34e5ba
gh-106052: Fix bug in the matching of possessive quantifiers (gh-106515)
It did not work in the case of a subpattern containing backtracking.

Temporary implement possessive quantifiers as equivalent greedy qualifiers
in atomic groups.
2023-08-09 08:47:57 +03:00
Gertjan van Zwieten 8579327879
gh-107715: Escape class name in regular expression (GH-107716)
This patch escapes the class name before embedding it in the regular expression
for `pat` in `doctest.DocTestFinder._find_lineno`. While class names do not
ordinarily contain special characters, it is possible to encounter these when a
class is created dynamically. Escaping the name will correctly return `None` in
this scenario, rather than potentially matching a different class or raising
`re.error` depending on the symbols used.
2023-08-07 18:24:02 +03:00
Serhiy Storchaka ed64204716
gh-106566: Optimize (?!) in regular expressions (GH-106567) 2023-08-07 18:09:56 +03:00
Serhiy Storchaka 50e3cc9748
gh-100814: Fix exception for invalid callable value of Tkinter image option (GH-107692)
Passing a callable object as an option value to a Tkinter image now raises
the expected TclError instead of an AttributeError.
2023-08-07 17:38:55 +03:00
Nikita Sobolev 8fcee6b279
gh-107710: Speed up `logging.getHandlerNames` function (#107711) 2023-08-07 14:52:36 +01:00
Pieter Eendebak 3e334ae259
gh-85160: improve performance of `functools.singledispatchmethod` (#107148)
Co-authored-by: mental <m3nta1@yahoo.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-06 13:37:12 +01:00
Kumar Aditya 41178e4199
GH-106684: raise `ResourceWarning` when `asyncio.StreamWriter` is not closed (#107650) 2023-08-05 17:48:15 +05:30
Barney Gale ec0a0d2bd9
GH-70303: Emit FutureWarning when pathlib glob pattern ends with `**` (GH-105413)
In a future Python release, patterns with this ending will match both files
and directories. Users may add a trailing slash to remove the warning.
2023-08-04 23:12:12 +00:00
James Hilton-Balfe ed4a978449
gh-107576: Ensure `__orig_bases__` are our own in `get_original_bases` (#107584)
Co-authored-by: Chris Bouchard <chris@upliftinglemma.net>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-03 14:19:24 +00:00
Pablo Galindo Salgado 77e09192b5
gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (#107586)
Co-authored-by: T. Wouters <thomas@python.org>
2023-08-03 12:37:14 +00:00
Irit Katriel dd693d6320
gh-105481: simplify definition of pseudo ops in Lib/opcode.py (#107561) 2023-08-02 18:16:57 +01:00
Irit Katriel 6ef8f8ca88
gh-105481: the ENABLE_SPECIALIZATION flag does not need to be generated by the build script, or exposed in opcode.py (#107534) 2023-08-01 17:05:00 +00:00
Pieter Eendebak f7c9144c2c
gh-89013: Improve the performance of methodcaller (lazy version) (gh-107201) 2023-08-01 15:45:51 +09:00
Michael The a22ff8e11c
gh-105578: Document that `AnyStr` is deprecated in py313 (#107116)
It will not be removed until Python 3.18.
2023-07-31 15:43:53 +00:00
opavliuk f22bf8e3cf
gh-87799: Improve the textual representation of IPv4-mapped IPv6 addresses (#29345)
Represent IPv4-mapped IPv6 address as xxxd.d.d.d,
where the 'x's are the hexadecimal values
of the six high-order 16-bit pieces of the address,
and the 'd's are the decimal values
of the four low-order 8-bit pieces of the address
(standard IPv4 representation).

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2023-07-31 14:33:26 +00:00
Konstantin 08447b5deb
gh-46376: Return existing pointer when possible in ctypes (#107131) 2023-07-31 09:10:53 +02:00
Charlie Zhao 3979150a0d
gh-106263: Fix segfault in `signaldict_repr` in `_decimal` module (#106270)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-07-30 13:58:54 +05:30
Inada Naoki 37551c9cef
gh-107369: optimize textwrap.indent() (#107374) 2023-07-29 06:37:23 +00:00
James Cave 810d5d87d9
gh-107089: Improve Shelf.clear method performance (gh-107090) 2023-07-29 09:08:11 +09:00
János Kukovecz e7e6e4b035
gh-105002: [pathlib] Fix relative_to with walk_up=True using ".." (#107014)
It makes sense to raise an Error because ".." can not
be resolved and the current working directory is unknown.
2023-07-26 20:44:55 +01:00
Christopher Chavez b5ae7c4984
gh-106350: Tkinter: do not ignore return value of `mp_init()` (GH-106351) 2023-07-25 21:52:07 +03:00
shailshouryya fabcbe9c12
gh-106739: Add `rtype_cache` to `warnings.warn` message when leaked objects found (#106740)
Adding the `rtype_cache` to the `warnings.warn` message improves the
previous, somewhat vague message from

```
/Users/username/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown
```

to

```
/Users/username/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown: {'/mp-yor5cvj8', '/mp-10jx8eqr', '/mp-eobsx9tt', '/mp-0lml23vl', '/mp-9dgtsa_m', '/mp-frntyv4s'}
```

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-07-25 17:27:36 +00:00
Paul Moore f443b54a2f
gh-106774: Update bundled pip version to 23.2.1 (#106775)
* Update bundled pip version to 23.2.1
2023-07-25 10:59:25 +01:00
Tomas R b3c34e55c0
gh-62519: Make pgettext search plurals when translation is not found (#107118)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-07-23 16:08:28 +02:00
htsedebenham c65592c4d6
gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only (#107016) 2023-07-23 12:25:18 +02:00
Gilles Bassière 54632528ee
bpo-18319: gettext() can retrieve a message even if a plural form exists (#19869) 2023-07-23 11:59:19 +02:00
J. Nick Koston 9eeb4b485f
gh-82500: Fix asyncio sendfile overflow on 32bit (#107056) 2023-07-22 21:07:14 -07:00
J. Nick Koston b7dc795dfd
gh-106527: asyncio: optimize to add/remove readers and writers (#106528) 2023-07-22 21:07:40 +00:00
Matthieu Caneill 6e5f2235f3
gh-83006: Document behavior of `shutil.disk_usage` for non-mounted filesystems on Unix (#107031) 2023-07-22 17:58:06 +02:00
Matthieu Caneill 3782def5a2
gh-65495: Use lowercase `mail from` and `rcpt to` in `smtplib.SMTP` (#107019)
Use lowercase `mail from` and `rcpt to` in `smtplib.SMTP`

SMTP commands are case-insensitive. `smtplib` uses lowercase commands,
however it writes `mail FROM` and `rcpt TO`, lacking consistency.
2023-07-22 16:46:59 +02:00
Pieter Eendebak 832c37d42a
gh-106751: Optimize _PolllikeSelector for many iteration case (gh-106884) 2023-07-20 09:53:11 +09:00
Barney Gale c6c5665ee0
GH-100502: Add `pathlib.PurePath.pathmod` attribute (GH-106533)
This instance attribute stores the implementation of `os.path` used for
low-level path operations: either `posixpath` or `ntpath`.
2023-07-19 18:59:55 +01:00
Dong-hee Na e6f96cf9c6
gh-106751: Optimize SelectSelector.select() for many iteration case (gh-106879) 2023-07-19 15:12:38 +09:00
Dong-hee Na 7513e2e7e4
gh-106751: Optimize KqueueSelector.select() for many iteration case (gh-106864) 2023-07-19 10:18:23 +09:00
Tian Gao 663854d73b
gh-106727: Make `inspect.getsource` smarter for class for same name definitions (#106815) 2023-07-18 23:20:31 +00:00
Irit Katriel 40f3f11a77
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758) 2023-07-18 19:42:44 +01:00
J. Nick Koston aecf6aca51
gh-106751: selectors: optimize EpollSelector.select() (#106754)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2023-07-18 10:16:32 +00:00
Nikita Sobolev ebf2c56b33
gh-106831: Fix NULL check of d2i_SSL_SESSION() result in _ssl.c (#106832) 2023-07-17 19:55:40 +00:00
Irit Katriel 5ecedbd266
gh-106789: avoid importing pprint from sysconfig (#106790) 2023-07-17 10:28:33 +01:00
Grigoriev Semyon 55408f86d7
gh-105726: Add `__slots__` to `AbstractContextManager` and `AbstractAsyncContextManager` (#106771)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-07-16 15:30:39 +00:00
Jason R. Coombs 22980dc7c9
gh-106752: Sync with zipp 3.16.2 (#106757)
* gh-106752: Sync with zipp 3.16.2

* Add blurb
2023-07-15 09:21:17 -04:00
J. Nick Koston aeef8591e4
gh-106554: replace `_BaseSelectorImpl._key_from_fd` with `dict.get` (#106555) 2023-07-15 03:46:30 +09:00
Irit Katriel 6a70edf24c
gh-105481: expose opcode metadata via the _opcode module (#106688) 2023-07-14 18:41:52 +01:00
Jason R. Coombs 243fdcb40e
gh-106531: Remove importlib.resources._legacy (#106532)
* gh-106531: Remove importlib.resources._legacy

Syncs with importlib_resources 6.0.

* Remove documentation for removed functionality.
2023-07-14 13:38:28 -04:00
Grant Ramsay 21d98be422
gh-105293: Do not call SSL_CTX_set_session_id_context on client side SSL context (#105295)
* gh-105293: Do not call SSL_CTX_set_session_id_context on client side SSL context

Openssl states this is a "server side only" operation.
Calling this on a client side socket can result in unexpected behavior

* Add news entry on SSL "set session id context" changes
2023-07-14 00:10:54 -07:00
Nikita Sobolev 490295d651
gh-105626: Change the default return value of `HTTPConnection.get_proxy_response_headers` (#105628) 2023-07-13 23:55:49 -07:00
J. Nick Koston 8d2f3c36ca
gh-106664: selectors: add get() method to _SelectorMapping (#106665)
It can be used to avoid raising and catching KeyError twice via __getitem__.

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2023-07-13 19:18:53 +00:00
Alex Waygood 32718f908c
gh-106309: Deprecate typing.no_type_check_decorator (#106312) 2023-07-13 14:30:35 +01:00
CF Bolz-Tereick 7e6ce48872
gh-106628: email parsing speedup (gh-106629) 2023-07-13 15:12:56 +09:00
Jim Porter af51bd7cda
gh-89427: Set VIRTUAL_ENV_PROMPT even when VIRTUAL_ENV_DISABLE_PROMPT… (GH-106643) 2023-07-13 07:08:33 +01:00
Prince Roshan 357e9e9da3
gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106666) 2023-07-12 14:01:17 -07:00
Nikita Sobolev e4b88c1e4a
gh-106236: Replace `assert` with `raise RuntimeError` in `threading.py` (#106237)
Replace `assert` with `raise ` in `threading.py` so that -OO does not alter _DummyThread behavior.
2023-07-12 11:07:59 -07:00
Jelle Zijlstra 945d3cbf2e
gh-106403: Restore weakref support for TypeVar and friends (#106418) 2023-07-11 08:43:24 -07:00
Terry Jan Reedy a2d54d4e8a
gh-106498: Revert incorrect colorsys.rgb_to_hls change (#106627)
gh-86618 assumed a-b-c = a-(b+c) = a-d where d = b+d.
For floats 2.0, 1.0, and 0.9999999999999999, this assumption
is false.  The net change of 1.1102230246251565e-16 to 0.0
results in division by 0.  Revert the replacement.  Add test.
2023-07-11 11:07:20 -04:00
Ethan Furman 95b7426f45
gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (#106468)
For example:

    class Flag(enum.Flag):
        A = 0x01
        B = 0x02
        MASK = 0xff

    ~Flag.MASK is Flag(0)
2023-07-11 13:35:54 +02:00
Louis Paulot 6782fc0502
gh-94777: Fix deadlock in ProcessPoolExecutor (#94784)
Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe.  See GH-94777 for more details.
2023-07-10 21:45:27 +00:00
Victor Stinner dcc028d924
gh-105376: Remove logging.warn() and LoggerAdapter.warn() (#106553) 2023-07-09 10:32:50 +02:00
Serhiy Storchaka 74ec02e949
gh-106510: Fix DEBUG output for atomic group (GH-106511) 2023-07-08 14:31:25 +03:00
Radislav Chugunov 2ef1dc37f0
gh-106524: Fix a crash in _sre.template() (GH-106525)
Some items remained uninitialized if _sre.template() was called with invalid
indices. Then attempt to clear them in the destructor led to dereferencing
of uninitialized pointer.
2023-07-08 10:47:01 +03:00
Desmond Cheong 1fb9bd222b
gh-103200: Fix performance issues with `zipimport.invalidate_caches()` (GH-103208)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2023-07-07 22:02:13 +00:00
Andrew Geng 3e5ce7968f
gh-106503: asyncio._SelectorSocketTransport: fix cyclic reference on close(). (#106504) 2023-07-07 17:11:54 +05:30
Gregory P. Smith c60df361ce
gh-90876: Restore the ability to import multiprocessing when `sys.executable` is `None` (#106464)
Prevent `multiprocessing.spawn` from failing to *import* in environments
where `sys.executable` is `None`.  This regressed in 3.11 with the addition
of support for path-like objects in multiprocessing.

Adds a test decorator to have tests only run when part of test_multiprocessing_spawn to `_test_multiprocessing.py` so we can start to avoid re-running the same not-global-state specific test in all 3 modes when there is no need.
2023-07-06 22:46:50 +00:00
Ariel Eizenberg 99b00efd5e
gh-106238: Handle KeyboardInterrupt during logging._acquireLock() (GH-106239)
Co-authored-by: Ariel Eizenberg <ariel.eizenberg@pagaya.com>
2023-07-06 08:02:22 +01:00
Carl Meyer 838406b4fc
gh-106292: restore checking __dict__ in cached_property.__get__ (#106380)
* gh-106292: restore checking __dict__ in cached_property.__get__

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2023-07-05 17:01:35 -06:00
Barney Gale b4efdf8cda
GH-106330: Fix matching of empty path in `pathlib.PurePath.match()` (GH-106331)
We match paths using the `_lines` attribute, which is derived from the
path's string representation. The bug arises because an empty path's string
representation is `'.'` (not `''`), which is matched by the `'*'` wildcard.
2023-07-03 21:29:44 +01:00
Mario Corchero d65b783b69
gh-61215: New mock to wait for multi-threaded events to happen (#16094)
mock: Add `ThreadingMock` class

Add a new class that allows to wait for a call to happen by using
`Event` objects. This mock class can be used to test and validate
expectations of multithreading code.

It uses two attributes for events to distinguish calls with any argument
and calls with specific arguments.

The calls with specific arguments need a lock to prevent two calls in
parallel from creating the same event twice.

The timeout is configured at class and constructor level to allow users
to set a timeout, we considered passing it as an argument to the
function but it could collide with a function parameter. Alternatively
we also considered passing it as positional only but from an API
caller perspective it was unclear what the first number meant on the
function call, think `mock.wait_until_called(1, "arg1", "arg2")`, where
1 is the timeout.

Lastly we also considered adding the new attributes to magic mock
directly rather than having a custom mock class for multi threading
scenarios, but we preferred to have specialised class that can be
composed if necessary. Additionally, having added it to `MagicMock`
directly would have resulted in `AsyncMock` having this logic, which
would not work as expected, since when if user "waits" on a
coroutine does not have the same meaning as waiting on a standard
call.

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
2023-07-03 07:56:54 +01:00
Kirill Podoprigora 0530f4f646
gh-102541: Fix Helper.help("mod") for non-existent mod (#105934)
If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-07-01 18:46:06 -04:00
Tian Gao cea9d4ea82
GH-106152: Add PY_THROW event to cProfile (GH-106161) 2023-06-29 16:14:09 -07:00
Łukasz Langa d3af83b934
Revert "GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)" (#105948)
This reverts commit 1f0eafa844.
2023-06-26 20:35:53 +02:00
Barney Gale 219effa876
GH-105793: Add follow_symlinks argument to `pathlib.Path.is_dir()` and `is_file()` (GH-105794)
Brings `pathlib.Path.is_dir()` and `in line with `os.DirEntry.is_dir()`, which
will be important for implementing generic path walking and globbing.
Likewise `is_file()`.
2023-06-26 17:58:17 +01:00
Gabriel Venberg dac3d389e7
gh-104527: zippapp will now avoid appending an archive to itself. (gh-106076)
zippapp will now avoid appending an archive to itself.
2023-06-26 10:09:08 +01:00
James Webber a12e8ffb49
gh-106075: add `asyncio.taskgroups.__all__` to `asyncio.__all__` (#106090)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-06-26 07:54:03 +00:00
Alex Waygood 93a970ffbc
gh-106046: Improve error message from `os.fspath` if `__fspath__` is set to `None` (#106082) 2023-06-26 00:06:12 +01:00
chgnrdv d2cbb6e918
gh-105987: Fix reference counting issue in `_asyncio._swap_current_task` (#105989) 2023-06-24 10:53:24 +05:30
Alex Waygood 9499b0f138
gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom `__subclasshook__` methods (#105976) 2023-06-23 14:59:25 +00:00
Barney Gale a8006706f7
GH-89812: Add `pathlib.UnsupportedOperation` (GH-105926)
This new exception type is raised instead of `NotImplementedError` when
a path operation is not supported. It can be raised from `Path.readlink()`,
`symlink_to()`, `hardlink_to()`, `owner()` and `group()`. In a future
version of pathlib, it will be raised by `AbstractPath` for these methods
and others, such as `AbstractPath.mkdir()` and `unlink()`.
2023-06-22 14:35:51 +01:00
T. Wouters 1858db7cbd
GH-105808: Fix a regression introduced in GH-101251 (#105910)
Fix a regression introduced in pythonGH-101251, causing GzipFile.flush() to
not flush the compressor (nor pass along the zip_mode argument).
2023-06-19 17:09:04 +00:00
Irit Katriel 14d01262da
gh-105481: remove HAS_ARG, HAS_CONST, IS_JUMP_OPCODE, IS_PSEUDO_OPCODE and replace by their new versions (#105865) 2023-06-17 17:00:16 +01:00
Jelle Zijlstra 957a974d4f
gh-104799: PEP 695 backward compatibility for ast.unparse (#105846) 2023-06-16 09:31:23 -07:00
Tian Gao 25a64fd28a
GH-103124: Multiline statement support for pdb (GH-103125) 2023-06-15 23:34:42 +00:00
Alex Waygood 7b1f0f204a
gh-105570: Deprecate unusual ways of creating empty TypedDicts (#105780)
Deprecate two methods of creating typing.TypedDict classes with 0 fields using the functional syntax: `TD = TypedDict("TD")` and `TD = TypedDict("TD", None)`. Both will be disallowed in Python 3.15. To create a TypedDict class with 0 fields, either use `class TD(TypedDict): pass` or `TD = TypedDict("TD", {})`.
2023-06-14 14:58:41 +00:00
Alex Waygood ad56340b66
gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes (#105609)
Deprecate creating a typing.NamedTuple class using keyword arguments to denote the fields (`NT = NamedTuple("NT", x=int, y=str)`). This will be disallowed in Python 3.15. Use the class-based syntax or the functional syntax instead.

Two methods of creating `NamedTuple` classes with 0 fields using the functional syntax are also deprecated, and will be disallowed in Python 3.15: `NT = NamedTuple("NT")` and `NT = NamedTuple("NT", None)`. To create a `NamedTuple` class with 0 fields, either use `class NT(NamedTuple): pass` or `NT = NamedTuple("NT", [])`.
2023-06-14 13:38:49 +01:00
Jelle Zijlstra fc8037d84c
gh-104873: Add typing.get_protocol_members and typing.is_protocol (#104878)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-14 05:35:06 -07:00
Kirill Podoprigora ba516e70c6
gh-102541: Hide traceback in help prompt (gh-102614) 2023-06-14 21:17:12 +09:00
Nikita Sobolev e5d45b7444
gh-105745: Fix open method of webbrowser.Konqueror (#105746) 2023-06-14 12:29:16 +02:00
Nikita Sobolev 67f69dba0a
gh-105687: Remove deprecated objects from `re` module (#105688) 2023-06-14 12:26:20 +02:00
zentarim f3266c05b6
GH-104554: Add RTSPS support to `urllib/parse.py` (#104605)
* GH-104554: Add RTSPS support to `urllib/parse.py`

RTSPS is the permanent scheme defined in
https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
alongside RTSP and RTSPU schemes.

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-06-13 16:45:47 -07:00
Victor Stinner 2211454fe2
gh-105733: Deprecate ctypes SetPointerType() and ARRAY() (#105734) 2023-06-13 18:16:26 +00:00
Erlend E. Aasland 217589d4f3
gh-105375: Improve error handling in _Unpickler_SetInputStream() (#105667)
Prevent exceptions from possibly being overwritten in case of multiple
failures.
2023-06-13 10:38:01 +02:00
Kumar Aditya 840d02f3f0
GH-105684: Require `asyncio.Task` implementations to support `set_name` method (#105685) 2023-06-13 06:06:40 +00:00
Erlend E. Aasland 20a56d8bec
gh-105375: Harden pyexpat initialisation (#105606)
Add proper error handling to add_errors_module() to prevent exceptions
from possibly being overwritten.
2023-06-11 20:18:46 +00:00
Erlend E. Aasland 41cddc2e93
gh-105375: Improve error handling in the sys extension module (#105611)
In _PySys_AddXOptionWithError() and sys_add_xoption(),
bail on first error to prevent exceptions from possibly being
overwritten.
2023-06-11 20:02:49 +00:00
Erlend E. Aasland e8998e46a7
gh-105375: Improve error handling in _ctypes (#105593)
Prevent repeated PyLong_FromVoidPtr() from possibly overwriting the
current exception.
2023-06-11 19:46:19 +00:00
Samet YASLAN 3f7c0810f6
bpo-44185: Added close() to mock_open __exit__ (#26902) 2023-06-11 19:51:21 +01:00
Tomas R 18d16e93b6
gh-102676: Add more convenience properties to `dis.Instruction` (#103969)
Adds start_offset, cache_offset, end_offset, baseopcode,
baseopname, jump_target and oparg to dis.Instruction.

Also slightly improves the disassembly output by allowing
opnames to overflow into the space reserved for opargs.
2023-06-11 08:50:34 -07:00
Erlend E. Aasland c932f72849
gh-105375: Improve _decimal error handling (#105605)
Fix a bug where an exception could end up being overwritten.
2023-06-11 12:06:06 +02:00
Erlend E. Aasland 16d49680b5
gh-105375: Harden _datetime initialisation (#105604)
Improve error handling so init bails on the first exception.
2023-06-11 12:03:09 +02:00
Erlend E. Aasland 35cff545db
gh-105375: Improve array.array exception handling (#105594)
Fix a bug where 'tp_richcompare' could end up overwriting an exception.
2023-06-11 11:58:08 +02:00
Erlend E. Aasland 01f4230460
gh-105375: Harden _ssl initialisation (#105599)
Add proper error handling to prevent reference leaks and overwritten
exceptions.
2023-06-11 11:56:32 +02:00
Hugo van Kemenade cc879481e2
gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760) 2023-06-11 03:17:35 -06:00
Nikita Sobolev 33c92c4f15
gh-105375: Improve error handling in `zoneinfo` module (#105586)
Fix bugs where exceptions could end up being overwritten
because of deferred error handling.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 21:48:54 +00:00
Erlend E. Aasland 00b599ab5a
gh-105375: Improve error handling in _elementtree (#105591)
Fix bugs where exceptions could end up being overwritten.
2023-06-09 22:35:03 +02:00
Erlend E. Aasland f668f73bc8
gh-105375: Improve posix error handling (#105592)
Fix a bug where an IndexError could end up being overwritten.
2023-06-09 22:07:47 +02:00
Erlend E. Aasland eede1d2f48
gh-105375: Improve errnomodule error handling (#105590)
Bail immediately if an exception is set, to prevent exceptions from
being overwritten.
2023-06-09 21:57:25 +02:00
Erlend E. Aasland 89aac6f6b7
gh-105375: Improve _pickle error handling (#105475)
Error handling was deferred in some cases, which could potentially lead
to exceptions being overwritten.
2023-06-09 19:09:53 +02:00
Ethan Furman 59f009e589
gh-105497: [Enum] Fix Flag inversion when alias/mask members exist. (GH-105542)
When inverting a Flag member (or boundary STRICT), only consider other canonical flags; when inverting an IntFlag member (or boundary KEEP), also consider aliases.
2023-06-09 08:56:05 -07:00
Thomas Grainger 9bf8d825a6
gh-94924: support `inspect.iscoroutinefunction` in `create_autospec(async_def)` (#94962)
* support inspect.iscoroutinefunction in create_autospec(async_def)

* test create_autospec with inspect.iscoroutine and inspect.iscoroutinefunction

* test when create_autospec functions check their signature
2023-06-09 13:29:09 +00:00
Nikita Sobolev 947ec7ab02
gh-105545: Remove deprecated `MacOSXOSAScript._name` (gh-105546) 2023-06-09 08:52:58 +00:00
Nikita Sobolev 4ff5690e59
gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348)
* revert enum pickling from by-name to by-value

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2023-06-08 11:40:15 -07:00
Eric Snow 34c63b86d3
gh-104310: Rename the New Function in importlib.util (gh-105255)
The original name wasn't as clear as it could have been. This change includes the following:

* rename the function
* change the default value for "disable_check" to False
* add clues to the docstring that folks should probably not use the function

---------

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2023-06-08 18:19:58 +00:00
Barney Gale ffeaec7e60
GH-104996: Defer joining of `pathlib.PurePath()` arguments. (GH-104999)
Joining of arguments is moved to `_load_parts`, which is called when a
normalized path is needed.
2023-06-07 23:27:06 +01:00
Erlend E. Aasland a24a780d93
gh-105375: Improve error handling in sqlite3 collation callback (#105412)
Check for error after each call to PyUnicode_FromStringAndSize().
2023-06-07 13:10:28 +02:00
Barney Gale 24af45172f
GH-102613: Fast recursive globbing in `pathlib.Path.glob()` (GH-104512)
This commit introduces a 'walk-and-match' strategy for handling glob patterns that include a non-terminal `**` wildcard, such as `**/*.py`. For this example, the previous implementation recursively walked directories using `os.scandir()` when it expanded the `**` component, and then **scanned those same directories again** when expanded the `*.py` component. This is wasteful.

In the new implementation, any components following a `**` wildcard are used to build a `re.Pattern` object, which is used to filter the results of the recursive walk. A pattern like `**/*.py` uses half the number of `os.scandir()` calls; a pattern like `**/*/*.py` a third, etc.

This new algorithm does not apply if either:

1. The *follow_symlinks* argument is set to `None` (its default), or
2. The pattern contains `..` components.

In these cases we fall back to the old implementation.

This commit also replaces selector classes with selector functions. These generators directly yield results rather calling through to their successors. A new internal `Path._glob()` method takes care to chain these generators together, which simplifies the lazy algorithm and slightly improves performance. It should also be easier to understand and maintain.
2023-06-06 23:50:36 +01:00
Victor Stinner 2587b9f64e
gh-105382: Remove urllib.request cafile parameter (#105384)
Remove cafile, capath and cadefault parameters of the
urllib.request.urlopen() function, deprecated in Python 3.6.
2023-06-06 21:17:45 +00:00
Victor Stinner 6c54e5d721
gh-105376: Remove logging.Logger.warn() method (#105377) 2023-06-06 18:35:51 +00:00
Victor Stinner 0cb6b9b0db
gh-104783: Remove locale.resetlocale() function (#104784) 2023-06-06 14:55:50 +02:00
Irit Katriel f4d8e10d0d
gh-105292: Add option to make traceback.TracebackException.format_exception_only recurse into exception groups (#105294)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-06-06 11:26:18 +02:00
Christopher Chavez 00d73caf80
gh-104399: Use newer libtommath APIs when necessary (GH-104407) 2023-06-06 09:52:07 +03:00
Alex Waygood 08756dbba6
gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always evaluates to `False` (#105281) 2023-06-05 14:10:49 +00:00
Alex Waygood cdfb201bfa
gh-105237: Allow calling `issubclass(X, typing.Protocol)` again (#105239) 2023-06-05 06:36:51 -07:00
Tian Gao 9efaff5fd3
gh-103558: Add coverage tests for argparse (#103570)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
2023-06-05 00:14:00 -07:00
Inada Naoki 1237fb6a4b
gh-80480: array: Add 'w' typecode. (#105242) 2023-06-04 16:45:00 +00:00
Tian Gao 9ad199ba36
gh-105080: Fixed inconsistent signature on derived classes (#105217) 2023-06-02 16:22:33 -06:00
Tian Gao d944d873b2
gh-103464: Add checks for arguments of pdb commands (GH-103465) 2023-05-31 20:51:46 +00:00
Alex Waygood c05c31db8c
gh-105144: Runtime-checkable protocols: move all 'sanity checks' to `_ProtocolMeta.__subclasscheck__` (#105152) 2023-05-31 17:02:25 +00:00
Victor Stinner 03ad6624c2
gh-105096: Deprecate wave getmarkers() method (#105098)
wave: Deprecate the getmark(), setmark() and getmarkers() methods of
the Wave_read and Wave_write classes. They will be removed in Python
3.15.
2023-05-31 12:09:41 +00:00
Victor Stinner 58a2e09816
gh-62948: IOBase finalizer logs close() errors (#105104) 2023-05-31 11:41:19 +00:00
Barney Gale 49f90ba1ea
GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` (#101398)
`PurePath.match()` now handles the `**` wildcard as in `Path.glob()`, i.e. it matches any number of path segments.

We now compile a `re.Pattern` object for the entire pattern. This is made more difficult by `fnmatch` not treating directory separators as special when evaluating wildcards (`*`, `?`, etc), and so we arrange the path parts onto separate *lines* in a string, and ensure we don't set `re.DOTALL`.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-30 20:18:09 +00:00
Barney Gale ace676e2c2
GH-77609: Add follow_symlinks argument to `pathlib.Path.glob()` (GH-102616)
Add a keyword-only *follow_symlinks* parameter to `pathlib.Path.glob()` and`rglob()`.

When *follow_symlinks* is `None` (the default), these methods follow symlinks except when evaluating "`**`" wildcards. When set to true or false, symlinks are always or never followed, respectively.
2023-05-29 16:59:52 +01:00
Hugo van Kemenade b225c08de8
gh-104992: Remove deprecated unittest.TestProgram.usageExit (#104993) 2023-05-27 21:34:14 +00:00
Zachary Ware a989b73e8e
gh-75552: Remove deprecated tkinter.tix module (GH-104902) 2023-05-27 12:34:19 -05:00
Raymond Hettinger 402ee5a68b
GH-101588: Deprecate pickle/copy/deepcopy support in itertools (GH-104965) 2023-05-26 15:32:53 -05:00
Barney Gale 328422ce61
GH-103631: Fix `PurePosixPath(PureWindowsPath(...))` separator handling (GH-104949)
For backwards compatibility, accept backslashes as path separators in
`PurePosixPath` if an instance of `PureWindowsPath` is supplied.
This restores behaviour from Python 3.11.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-26 18:05:43 +00:00
Barney Gale ad0be361c9
GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms (GH-104948)
Use `str.lower()` rather than `ntpath.normcase()` to normalize case of
Windows paths. This restores behaviour from Python 3.11.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-26 18:04:02 +00:00
Hugo van Kemenade 5ab4bc05c4
gh-104804: Remove webbrowser.MacOSX class, deprecated in Python 3.11 (#104816)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-26 16:54:15 +03:00
Victor Stinner e399f46a77
gh-104773: PEP 594: Remove the imghdr module (#104777)
* Remove the Lib/test/imghdrdata/ directory.
* Copy 5 pictures (gif, png, ppm, pgm, xbm) from removed
  Lib/test/imghdrdata/ to a new Lib/test/tkinterdata/ directory.
* Update Sphinx from 4.5 to 6.2 in Doc/requirements.txt.
2023-05-26 13:29:45 +00:00
Jelle Zijlstra ba73473f4c
gh-104799: Move location of type_params AST fields (#104828)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-26 05:54:37 -07:00
Hugo van Kemenade 3f9c60f51e
gh-104886: Remove deprecated configparser.LegacyInterpolation (#104887)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-26 06:06:32 +00:00
Andrii Kuzmin 0242e9a57a
gh-102024: Reduced _idle_semaphore.release calls (#102025)
Reduced _idle_semaphore.release calls in concurrent.futures.thread._worker
_idle_semaphore.release() is now only called if only work_queue is empty.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-05-25 22:48:40 -07:00
Hugo van Kemenade 10c45838e1
gh-104876: Remove deprecated turtle.RawTurtle.settiltangle (#104877)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-26 07:25:52 +03:00
Barney Gale bd1b6228d1
GH-104898: Add __slots__ to os.PathLike (GH-104899) 2023-05-25 21:24:20 +01:00
Tomas R fea8632ec6
gh-104786: Remove kwargs-based TypedDict creation (#104891)
Deprecated since Python 3.11.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-25 21:14:58 +01:00
Gregory P. Smith d08679212d
gh-104372: Drop the GIL around the vfork() call. (#104782)
On Linux where the `subprocess` module can use the `vfork` syscall for
faster spawning, prevent the parent process from blocking other threads
by dropping the GIL while it waits for the vfork'ed child process `exec`
outcome.  This prevents spawning a binary from a slow filesystem from
blocking the rest of the application.

Fixes #104372.
2023-05-25 20:14:09 +00:00
Jelle Zijlstra 2b7027d0b2
gh-104935: typing: Fix interactions between `@runtime_checkable` and `Generic` (#104939)
---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-25 16:43:40 +00:00
Victor Stinner 77d7ec5aa9
gh-104773: PEP 594: Remove the chunk module (#104868)
The module had no tests.
2023-05-25 16:27:55 +00:00
Victor Stinner f66be6b11a
gh-104773: PEP 594: Remove the audioop module (#104937) 2023-05-25 17:59:00 +02:00
Victor Stinner 036da3bd43
gh-104773: PEP 594: Remove the aifc module (#104933)
* Remove .aifc and .aiff test files of Lib/test/audiodata/
* Remove Lib/test/Sine-1000Hz-300ms.aif test file
2023-05-25 17:20:48 +02:00
Victor Stinner dbc8216f4c
gh-104773: PEP 594: Remove the uu module (#104932)
Doc/license.rst: Keep the UUencode and UUdecode license since it's
also used by the uu codec.
2023-05-25 16:25:27 +02:00
Victor Stinner e4127eaa1e
gh-104773: PEP 594: Remove the crypt module (#104908)
Remove the crypt module and its private _crypt extension, deprecated
in Python 3.11.
2023-05-25 15:45:46 +02:00
Zachary Ware 98c4333e88
gh-104773: Remove the msilib package (GH-104911) 2023-05-24 20:06:00 -05:00
Jelle Zijlstra 41768a2bd3
gh-104874: Document NewType.__supertype__ (#104875) 2023-05-25 00:23:28 +01:00