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
2 changes: 1 addition & 1 deletion Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ Object Protocol

Clear the managed dictionary of *obj*.

This function must only be called in a traverse function of the type which
This function must only be called in a clear function of the type which
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.

.. versionadded:: 3.13
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
:c:func:`Py_CLEAR` macro performs the operations in a safe order.

If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
:c:member:`~PyTypeObject.tp_flags` field, the traverse function must call
:c:member:`~PyTypeObject.tp_flags` field, the clear function must call
:c:func:`PyObject_ClearManagedDict` like this::

PyObject_ClearManagedDict((PyObject*)self);
Expand Down
52 changes: 41 additions & 11 deletions Doc/library/turtle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,17 @@ Turtle motion
180.0


.. function:: dot(size=None, *color)
.. function:: dot()
dot(size)
dot(color, /)
dot(size, color, /)
dot(size, r, g, b, /)

:param size: an integer >= 1 (if given)
:param color: a colorstring or a numeric color tuple

Draw a circular dot with diameter *size*, using *color*. If *size* is
not given, the maximum of pensize+4 and 2*pensize is used.
not given, the maximum of ``pensize+4`` and ``2*pensize`` is used.


.. doctest::
Expand Down Expand Up @@ -1152,7 +1156,9 @@ Drawing state
Color control
~~~~~~~~~~~~~

.. function:: pencolor(*args)
.. function:: pencolor()
pencolor(color, /)
pencolor(r, g, b, /)

Return or set the pencolor.

Expand All @@ -1161,7 +1167,7 @@ Color control
``pencolor()``
Return the current pencolor as color specification string or
as a tuple (see example). May be used as input to another
color/pencolor/fillcolor call.
color/pencolor/fillcolor/bgcolor call.

``pencolor(colorstring)``
Set pencolor to *colorstring*, which is a Tk color specification string,
Expand Down Expand Up @@ -1201,7 +1207,9 @@ Color control
(50.0, 193.0, 143.0)


.. function:: fillcolor(*args)
.. function:: fillcolor()
fillcolor(color, /)
fillcolor(r, g, b, /)

Return or set the fillcolor.

Expand All @@ -1210,7 +1218,7 @@ Color control
``fillcolor()``
Return the current fillcolor as color specification string, possibly
in tuple format (see example). May be used as input to another
color/pencolor/fillcolor call.
color/pencolor/fillcolor/bgcolor call.

``fillcolor(colorstring)``
Set fillcolor to *colorstring*, which is a Tk color specification string,
Expand Down Expand Up @@ -1244,7 +1252,10 @@ Color control
(255.0, 255.0, 255.0)


.. function:: color(*args)
.. function:: color()
color(color, /)
color(r, g, b, /)
color(pencolor, fillcolor, /)

Return or set pencolor and fillcolor.

Expand Down Expand Up @@ -1870,13 +1881,32 @@ Most of the examples in this section refer to a TurtleScreen instance called
Window control
--------------

.. function:: bgcolor(*args)
.. function:: bgcolor()
bgcolor(color, /)
bgcolor(r, g, b, /)

:param args: a color string or three numbers in the range 0..colormode or a
3-tuple of such numbers
Return or set the background color of the TurtleScreen.

Four input formats are allowed:

``bgcolor()``
Return the current background color as color specification string or
as a tuple (see example). May be used as input to another
color/pencolor/fillcolor/bgcolor call.

``bgcolor(colorstring)``
Set the background color to *colorstring*, which is a Tk color
specification string, such as ``"red"``, ``"yellow"``, or ``"#33cc8c"``.

Set or return background color of the TurtleScreen.
``bgcolor((r, g, b))``
Set the background color to the RGB color represented by the tuple of
*r*, *g*, and *b*.
Each of *r*, *g*, and *b* must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see :func:`colormode`).

``bgcolor(r, g, b)``
Set the background color to the RGB color represented by *r*, *g*, and *b*. Each of
*r*, *g*, and *b* must be in the range 0..colormode.

.. doctest::
:skipif: _tkinter is None
Expand Down
61 changes: 23 additions & 38 deletions Doc/using/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ packages.
.. _windows-path-mod:
.. _launcher:

Python Install Manager
Python install manager
======================

Installation
Expand Down Expand Up @@ -103,7 +103,7 @@ Windows Server 2019, please see :ref:`pymanager-advancedinstall` below for more
information.


Basic Use
Basic use
---------

The recommended command for launching Python is ``python``, which will either
Expand Down Expand Up @@ -193,7 +193,7 @@ installed if automatic installation is configured (most likely by setting
``pymanager exec`` forms of the command were used.


Command Help
Command help
------------

The ``py help`` command will display the full list of supported commands, along
Expand All @@ -218,7 +218,7 @@ override multiple settings at once. See :ref:`pymanager-config` below for more
information about these files.


Listing Runtimes
Listing runtimes
----------------

.. code::
Expand Down Expand Up @@ -259,7 +259,7 @@ For compatibility with the old launcher, the ``--list``, ``--list-paths``,
additional options, and will produce legacy formatted output.


Installing Runtimes
Installing runtimes
-------------------

.. code::
Expand Down Expand Up @@ -298,7 +298,7 @@ useful for embedding runtimes into larger applications.

.. _pymanager-offline:

Offline Installs
Offline installs
----------------

To perform offline installs of Python, you will need to first create an offline
Expand Down Expand Up @@ -330,7 +330,7 @@ In this way, Python runtimes can be installed and managed on a machine without
access to the internet.


Uninstalling Runtimes
Uninstalling runtimes
---------------------

.. code::
Expand Down Expand Up @@ -541,7 +541,7 @@ configuration option.

.. _pymanager-advancedinstall:

Advanced Installation
Advanced installation
---------------------

For situations where an MSIX cannot be installed, such as some older
Expand Down Expand Up @@ -635,7 +635,7 @@ the Store package in this way.

.. _pymanager-admin-config:

Administrative Configuration
Administrative configuration
----------------------------

There are a number of options that may be useful for administrators to override
Expand Down Expand Up @@ -726,17 +726,12 @@ directory containing the configuration file that specified them.

.. _install-freethreaded-windows:

Installing Free-threaded Binaries
Installing free-threaded binaries
---------------------------------

.. versionadded:: 3.13 (Experimental)
.. versionadded:: 3.13

.. note::

Everything described in this section is considered experimental,
and should be expected to change in future releases.

Pre-built distributions of the experimental free-threaded build are available
Pre-built distributions of the free-threaded build are available
by installing tags with the ``t`` suffix.

.. code::
Expand Down Expand Up @@ -885,7 +880,7 @@ versions before providing updates to users.

The two recommended use cases for this distribution are described below.

Python Application
Python application
------------------

An application written in Python does not necessarily require users to be aware
Expand Down Expand Up @@ -989,12 +984,7 @@ for the 64-bit version, `www.nuget.org/packages/pythonx86
Free-threaded packages
----------------------

.. versionadded:: 3.13 (Experimental)

.. note::

Everything described in this section is considered experimental,
and should be expected to change in future releases.
.. versionadded:: 3.13

Packages containing free-threaded binaries are named
`python-freethreaded <https://www.nuget.org/packages/python-freethreaded>`_
Expand Down Expand Up @@ -1046,7 +1036,7 @@ please install Python 3.12.

.. _max-path:

Removing the MAX_PATH Limitation
Removing the MAX_PATH limitation
================================

Windows historically has limited path lengths to 260 characters. This meant that
Expand Down Expand Up @@ -1332,7 +1322,7 @@ installation". In this case:
* Shortcuts are available for all users


Removing the MAX_PATH Limitation
Removing the MAX_PATH limitation
--------------------------------

Windows historically has limited path lengths to 260 characters. This meant that
Expand All @@ -1355,7 +1345,7 @@ After changing the above option, no further configuration is required.

.. _install-quiet-option:

Installing Without UI
Installing without UI
---------------------

All of the options available in the installer UI can also be specified from the
Expand Down Expand Up @@ -1504,7 +1494,7 @@ example file sets the same options as the previous example:

.. _install-layout-option:

Installing Without Downloading
Installing without downloading
------------------------------

As some features of Python are not included in the initial installer download,
Expand Down Expand Up @@ -1545,15 +1535,10 @@ settings and replace any that have been removed or modified.
:ref:`launcher`, which has its own entry in Programs and Features.


Installing Free-threaded Binaries
Installing free-threaded binaries
---------------------------------

.. versionadded:: 3.13 (Experimental)

.. note::

Everything described in this section is considered experimental,
and should be expected to change in future releases.
.. versionadded:: 3.13

To install pre-built binaries with free-threading enabled (see :pep:`703`), you
should select "Customize installation". The second page of options includes the
Expand Down Expand Up @@ -1585,7 +1570,7 @@ builds.
Free-threaded binaries are also available :ref:`on nuget.org <windows-nuget>`.


Python Launcher for Windows (Deprecated)
Python launcher for Windows (deprecated)
========================================

.. deprecated:: 3.14
Expand Down Expand Up @@ -1737,7 +1722,7 @@ have the script specify the version which should be used.
The key benefit of this is that a single launcher can support multiple Python
versions at the same time depending on the contents of the first line.

Shebang Lines
Shebang lines
-------------

If the first line of a script file starts with ``#!``, it is known as a
Expand Down Expand Up @@ -1949,7 +1934,7 @@ should allow you to see what versions of Python were located, why a
particular version was chosen and the exact command-line used to execute the
target Python. It is primarily intended for testing and debugging.

Dry Run
Dry run
-------

If an environment variable :envvar:`!PYLAUNCHER_DRYRUN` is set (to any value),
Expand Down
9 changes: 9 additions & 0 deletions Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ def _bootstrap(*, root=None, upgrade=False, user=False,

Note that calling this function will alter both sys.path and os.environ.
"""

try:
import zlib
except ImportError:
raise ModuleNotFoundError(
"ensurepip requires the standard library module 'zlib' "
"to install pip."
) from None

if altinstall and default_pip:
raise ValueError("Cannot use altinstall and default_pip together")

Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_ensurepip.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def setUp(self):
self.run_pip.return_value = 0
self.addCleanup(run_pip_patch.stop)

# Allow testing on zlib-less platforms by avoiding the check for zlib in _bootstrap()
zlib_patch = unittest.mock.patch.dict('sys.modules', {'zlib': unittest.mock.MagicMock()})
zlib_patch.start()
self.addCleanup(zlib_patch.stop)

# Avoid side effects on the actual os module
real_devnull = os.devnull
os_patch = unittest.mock.patch("ensurepip.os")
Expand Down Expand Up @@ -185,6 +190,16 @@ def test_pip_config_file_disabled(self):
ensurepip.bootstrap()
self.assertEqual(self.os_environ["PIP_CONFIG_FILE"], os.devnull)

def test_missing_zlib(self):
with unittest.mock.patch.dict('sys.modules', {'zlib': None}):
with self.assertRaises(ModuleNotFoundError) as cm:
ensurepip.bootstrap()

error_msg = str(cm.exception)
self.assertIn("ensurepip requires the standard library module 'zlib'", error_msg)

self.assertFalse(self.run_pip.called)

@contextlib.contextmanager
def fake_pip(version=ensurepip.version()):
if version is None:
Expand Down
Loading
Loading