]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-141412: Use reliable target URL for urllib example (GH-141474)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 12 Nov 2025 18:40:20 +0000 (19:40 +0100)
committerGitHub <noreply@github.com>
Wed, 12 Nov 2025 18:40:20 +0000 (18:40 +0000)
The endpoint used for demonstrating reading URLs is no longer
stable. This change substitutes a target over which we have more
control.
(cherry picked from commit fbcac799518e0cb29fcf5f84ed1fa001010b9073)

Co-authored-by: Bob Kline <bkline@users.noreply.github.com>
Doc/tutorial/stdlib.rst

index fc98ffaadeed88b1a9ce9b915d7646f1d6c00b93..163f3bdebd85464443c6cb85a6ef0697839233f6 100644 (file)
@@ -183,13 +183,13 @@ protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
 from URLs and :mod:`smtplib` for sending mail::
 
    >>> from urllib.request import urlopen
-   >>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:
+   >>> with urlopen('https://docs.python.org/3/') as response:
    ...     for line in response:
    ...         line = line.decode()             # Convert bytes to a str
-   ...         if line.startswith('datetime'):
+   ...         if 'updated' in line:
    ...             print(line.rstrip())         # Remove trailing newline
    ...
-   datetime: 2022-01-01T01:36:47.689215+00:00
+         Last updated on Nov 11, 2025 (20:11 UTC).
 
    >>> import smtplib
    >>> server = smtplib.SMTP('localhost')