In `__set_name__` there is a check for the `_value_` attribute and an attempt to add it if missing; this adds a test to cover the case for simple enums with a custom `__new__` method.
gvfs-open was deprecated in 2015 and removed in 2018, but its replacement,
gio(1), is not available in Ubuntu 16.04, which is apparently still
supported by CPython upstream even though it is considered to be EOL by
Ubuntu developers.
Signed-off-by: Simon McVittie <smcv@debian.org>
add tests that exercise the `_missing_` error path for `Flag` and `IntFlag`
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* bpo-20369: concurrent.futures.wait() now deduplicates futures given as arg.
* 📜🤖 Added by blurb_it.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
x_mul()'s squaring code can do some redundant and/or useless
work at the end of each digit pass. A more careful analysis
of worst-case carries at various digit positions allows
making that code leaner.
* bpo-46218: Change long_pow() to sliding window algorithm
The primary motivation is to eliminate long_pow's reliance on that the number of bits in a long "digit" is a multiple of 5. Now it no longer cares how many bits are in a digit.
But the sliding window approach also allows cutting the precomputed table of small powers in half, which reduces initialization overhead enough that the approach pays off for smaller exponents too. Depending on exponent bit patterns, a sliding window may also be able to save some bigint multiplies (sometimes when at least 5 consecutive exponent bits are 0, regardless of their starting bit position modulo 5).
Note: boosting the window width to 6 didn't work well overall. It give marginal speed improvements for huge exponents, but the increased overhead (the small-power table needs twice as many entries) made it a loss for smaller exponents.
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
The registry() method of functools.singledispatch() functions checks now
the first argument or the first parameter annotation and raises a TypeError if it is
not supported. Previously unsupported "types" were ignored (e.g. typing.List[int])
or caused an error at calling time (e.g. list[int]).
* Do not PUSH/POP traceback or type to the stack as part of exc_info
* Remove exc_traceback and exc_type from _PyErr_StackItem
* Add to what's new, because this change breaks things like Cython
* bpo-44893: Implement EntryPoint as simple class and deprecate tuple access in favor of attribute access. Syncs with importlib_metadata 4.8.1.
* Apply refactorings found in importlib_metadata 4.8.2.
Functions signal(), getsignal(), pthread_sigmask(), sigpending(),
sigwait() and valid_signals() were omitted.
If __all__ is not defined all non-builtin functions should have
correct __module__.
This parameter was accidentally removed when fixing
https://bugs.python.org/issue45129, this reverts the unnecessary changes
there.
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
`@dataclass` in 3.10 prohibits using list, dict, or set as default values. It does this to avoid the mutable default problem. This test is both too strict, and not strict enough. Too strict, because some immutable subclasses should be safe, and not strict enough, because other mutable types should be prohibited. With this change applied, `@dataclass` now uses unhashability as a proxy for mutability: if objects aren't hashable, they're assumed to be mutable.
The line numbers of actually calling the decorator functions of
functions and classes was wrong (as opposed to loading them, were they
have been correct previously too).
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This defines VPATH differently in PGO instrumentation builds, to account for a different default output directory. It also adds sys._vpath on Windows to make the value available to sysconfig so that it can be used in tests.
When Python is embedded in other applications, it is not easy to determine which version of Python is being used. This change exposes the Python version as part of the API data. Tools like Austin (https://github.com/P403n1x87/austin) can benefit from this data when targeting applications like uWSGI, as the Python version can then be inferred systematically by looking at the exported symbols rather than relying on unreliable pattern matching or other hacks (like remote code execution etc...).
Automerge-Triggered-By: GH:pablogsal
* Make generator, coroutine and async gen structs all the same size.
* Store interpreter frame in generator (and coroutine). Reduces the number of allocations neeeded for a generator from two to one.
The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code.
This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
Modify the ``EnumType.__dir__()`` and ``Enum.__dir__()`` to ensure
that user-defined methods and methods inherited from mixin classes always
show up in the output of `help()`. This change also makes it easier for
IDEs to provide auto-completion.
Rename PyConfig.no_debug_ranges to PyConfig.code_debug_ranges and
invert the value.
Document -X no_debug_ranges and PYTHONNODEBUGRANGES env var in
PyConfig.code_debug_ranges documentation.
* Inlined code from variance functions
* Added helper functions for the float square root of a fraction
* Call helper functions
* Add blurb
* Fix over-specified test
* Add a test for the _sqrt_frac() helper function
* Increase the tested range
* Add type hints to the internal function.
* Fix test for correct rounding
* Simplify ⌊√(n/m)⌋ calculation
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* Add comment and beef-up tests
* Test for zero denominator
* Add algorithmic references
* Add test for the _isqrt_frac_rto() helper function.
* Compute the 109 instead of hard-wiring it
* Stronger test for _isqrt_frac_rto()
* Bigger range
* Bigger range
* Replace float() call with int/int division to be parallel with the other code path.
* Factor out division. Update proof link. Remove internal type declaration
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* [bpo-43137](): webbrowser: Prefer gio open over gvfs-open
gvfs-open(1) was superseded by gio(1) in 2015, and removed from GNOME
releases in 2018. Debian and its derivatives like Ubuntu currently still
have a compatibility shim for gvfs-open, but we plan to remove it.
webbrowser prefers xdg-settings and xdg-open over gvfs-open, so this
will only have any practical effect on systems where the xdg-utils
package is not installed.
Note that we don't check for GNOME_DESKTOP_SESSION_ID before using gio.
gio does the right thing on any desktop environment that follows
freedesktop.org specifications, similar to xdg-settings, so it's
unnecessary to guard in this way. GNOME_DESKTOP_SESSION_ID was deprecated
in 2008 and removed from upstream gnome-session in 2018 (it's still
present in Debian/Ubuntu for backward compatibility, but probably
shouldn't be). The replacement way to detect a desktop environment is
the XDG_CURRENT_DESKTOP environment variable, which is a colon-separated
sequence where the first item is the current desktop environment and the
second and subsequent items (if present) are other desktop environments
that it resembles or is based on.
Resolves:
* [bpo-43137](): webbrowser: Never invoke gnome-open
gnome-open was part of GNOME 2, which was superseded in around 2010 and
is unmaintained. The replacement was gvfs-open, which was subsequently
replaced by gio(1) (as used in the previous commit).
* [bpo-43137](): webbrowser: Don't run gvfs-open on GNOME
gvfs-open was deprecated in 2015 and removed in 2018. The replacement
is gio(1) (as used in a previous commit).
GNOME_DESKTOP_SESSION_ID was deprecated in 2008 and removed in 2018.
The replacement is XDG_CURRENT_DESKTOP (as mentioned in a previous
commit).
---
To test this on a typical modern Linux system, it is necessary to disable the `xdg-settings` and `xdg-open` code paths, for example with this hack:
<details><summary>Hack to disable use of xdg-settings and xdg-open</summary>
```diff
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 3244f206aa..8f6c09d1d2 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -459,7 +459,7 @@ def open(self, url, new=0, autoraise=True):
def register_X_browsers():
# use xdg-open if around
- if shutil.which("xdg-open"):
+ if 0 and shutil.which("xdg-open"):
register("xdg-open", None, BackgroundBrowser("xdg-open"))
# Opens an appropriate browser for the URL scheme according to
@@ -549,7 +549,7 @@ def register_standard_browsers():
# Prefer X browsers if present
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
try:
- cmd = "xdg-settings get default-web-browser".split()
+ cmd = "false xdg-settings get default-web-browser".split()
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
result = raw_result.decode().strip()
except (FileNotFoundError, subprocess.CalledProcessError, PermissionError, NotADirectoryError) :
```
</details>
I haven't attempted to assess which of the specific web browsers such as Galeon are still extant, and which ones disappeared years ago. They could almost certainly be cleaned up, but that's beyond the scope of this PR.
* bpo-45514: Apply changes from importlib_resources@a3ef4128c6
* Mark legacy functions as deprecated in the docs and link to the migration docs in importlib_resources docs.
* Apply changes from importlib_resources@329ae9d5f2c.
* Indicate importlib.resources as a module.
Co-authored-by: Filipe Laíns <lains@riseup.net>