Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Doc/using/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ customization.
Python runtimes, or false to prevent it.
By default, true.

* - ``shebang_templates``
- (none)
- Mapping from shebang line template to alternative command, such as
``py -V:<tag>`` or a substitute string.
See :ref:`pymanager-shebang` for more details.

* - ``log_level``
- ``PYMANAGER_VERBOSE``, ``PYMANAGER_DEBUG``
- Set the default level of output (0-50).
Expand Down Expand Up @@ -568,6 +574,30 @@ which the path to the script and any additional arguments will be appended.
This functionality may be disabled by the ``shebang_can_run_anything``
configuration option.

Since version 26.3 of the Python install manager, custom shebang templates may
be added to your configuration file. Add the ``shebang_templates`` object with
one member for each template (the string to match) and the command to use when
the template is matched. Most commands should be ``py -V:<tag>`` (or ``pyw``) to
launch one of your installed runtimes. The ``py -3.<version>`` form is also
allowed, as is a plain ``py`` to launch the default. No other arguments are
supported.

.. code:: json5

{
"shebang_templates": {
"/usr/bin/python": "py",
"/usr/bin/my_custom_python": "py -V:MyCustomPython/3"
}
}

If the substitute command is not ``py`` or ``pyw``, it will be written back into
the shebang and regular handling continues. If launching arbitrary executables
is permitted, then providing a full path will allow you to redirect from Python
to any executable. The template should match either the entire line (ignoring
leading and trailing whitespace), or up to the first space in the shebang line.


.. note::

The behaviour of shebangs in the Python install manager is subtly different
Expand Down
24 changes: 15 additions & 9 deletions Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,32 +1620,38 @@ def __or__(self, other):
if other_value is NotImplemented:
return NotImplemented

for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with |")
value = self._value_
# _get_value(self) is self._value_ and _get_value(other) is
# other_value, so only walk the operands (to raise on the offending
# flag) when one of those values is actually None.
if value is None or other_value is None:
for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with |")
return self.__class__(value | other_value)

def __and__(self, other):
other_value = self._get_value(other)
if other_value is NotImplemented:
return NotImplemented

for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with &")
value = self._value_
if value is None or other_value is None:
for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with &")
return self.__class__(value & other_value)

def __xor__(self, other):
other_value = self._get_value(other)
if other_value is NotImplemented:
return NotImplemented

for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with ^")
value = self._value_
if value is None or other_value is None:
for flag in self, other:
if self._get_value(flag) is None:
raise TypeError(f"'{flag}' cannot be combined with other flags with ^")
return self.__class__(value ^ other_value)

def __invert__(self):
Expand Down
6 changes: 0 additions & 6 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
# reference any injected objects! This includes not only global code but also
# anything specified at the class level.

def _object_name(obj):
try:
return obj.__qualname__
except AttributeError:
return type(obj).__qualname__

# Bootstrap-related code ######################################################

# Modules injected manually by _setup()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Speed up the ``|``, ``&`` and ``^`` operations on :class:`enum.Flag` members.
Patch by Bern谩t G谩bor.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove the private, undocumented function
``importlib._bootstrap._object_name()``. It had no caller after
``load_module()`` and its deprecation warnings were removed from
:mod:`importlib`.
Loading