Skip to content

Commit 1297efe

Browse files
Deploy preview for PR 1226 🛫
1 parent 36c67a6 commit 1297efe

588 files changed

Lines changed: 713 additions & 665 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pr-preview/pr-1226/_sources/library/binascii.rst.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ The :mod:`!binascii` module defines the following functions:
158158
of hexadecimal digits (which can be upper or lower case), otherwise an
159159
:exc:`Error` exception is raised.
160160

161-
Similar functionality (accepting only text string arguments, but more
162-
liberal towards whitespace) is also accessible using the
163-
:meth:`bytes.fromhex` class method.
161+
Similar functionality (but more liberal towards whitespace) is also accessible
162+
using the :meth:`bytes.fromhex` class method.
164163

165164
.. exception:: Error
166165

pr-preview/pr-1226/_sources/library/copy.rst.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ file, socket, window, or any similar types. It does "copy" functions and
7272
classes (shallow and deeply), by returning the original object unchanged; this
7373
is compatible with the way these are treated by the :mod:`pickle` module.
7474

75-
Shallow copies of dictionaries can be made using :meth:`dict.copy`, and
76-
of lists by assigning a slice of the entire list, for example,
77-
``copied_list = original_list[:]``.
75+
Shallow copies of many collections can be made using the corresponding
76+
:meth:`!copy` method (such as :meth:`list.copy`, :meth:`dict.copy` or
77+
:meth:`set.copy`), and of sequences (such as lists or bytearrays) by making
78+
a slice of the entire sequence (``sequence[:]``).
79+
However, these methods and slicing can create an instance of the base type
80+
when copying an instance of a subclass, whereas :func:`copy.copy` normally
81+
returns an instance of the same type.
7882

7983
.. index:: pair: module; pickle
8084

pr-preview/pr-1226/_sources/library/math.rst.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,12 @@ Floating point manipulation functions
321321

322322
.. function:: frexp(x)
323323

324-
Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a float
325-
and *e* is an integer such that ``x == m * 2**e`` exactly. If *x* is zero,
326-
returns ``(0.0, 0)``, otherwise ``0.5 <= abs(m) < 1``. This is used to "pick
327-
apart" the internal representation of a float in a portable way.
324+
Return the mantissa and exponent of *x* as the pair ``(m, e)``.
325+
If *x* is a finite nonzero number, then *m* is a float with
326+
``0.5 <= abs(m) < 1.0`` and an integer *e* is such that
327+
``x == m * 2**e`` exactly. Else, return ``(x, 0)``.
328+
This is used to "pick apart" the internal representation of
329+
a float in a portable way.
328330

329331
Note that :func:`frexp` has a different call/return pattern
330332
than its C equivalents: it takes a single argument and return a pair of

pr-preview/pr-1226/_sources/library/mimetypes.rst.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ it converts file extensions to MIME types.
350350

351351
For each ``type`` entry, the script writes a line into the standard output
352352
stream. If an unknown type occurs, it writes an error message into the
353-
standard error stream and exits with the return code ``1``.
353+
standard output stream and exits with the return code ``1``.
354354

355355

356356
.. mimetypes-cli-example:
@@ -377,7 +377,7 @@ interface:
377377
378378
$ # get a MIME type for a rare file extension
379379
$ python -m mimetypes filename.pict
380-
error: unknown extension of filename.pict
380+
error: media type unknown for filename.pict
381381
382382
$ # now look in the extended database built into Python
383383
$ python -m mimetypes --lenient filename.pict
@@ -399,7 +399,8 @@ interface:
399399
$ python -m mimetypes filename.sh filename.nc filename.xxx filename.txt
400400
type: application/x-sh encoding: None
401401
type: application/x-netcdf encoding: None
402-
error: unknown extension of filename.xxx
402+
error: media type unknown for filename.xxx
403+
type: text/plain encoding: None
403404
404405
$ # try to feed an unknown MIME type
405406
$ python -m mimetypes --extension audio/aac audio/opus audio/future audio/x-wav

pr-preview/pr-1226/_sources/library/multiprocessing.rst.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ To show the individual process IDs involved, here is an expanded example::
100100
For an explanation of why the ``if __name__ == '__main__'`` part is
101101
necessary, see :ref:`multiprocessing-programming`.
102102

103-
The arguments to :class:`Process` usually need to be unpickleable from within
104-
the child process. If you tried typing the above example directly into a REPL it
105-
could lead to an :exc:`AttributeError` in the child process trying to locate the
106-
*f* function in the ``__main__`` module.
103+
The arguments to :class:`Process` usually need to be picklable so they can be
104+
passed to the child process. If you tried typing the above example directly
105+
into a REPL it could lead to an :exc:`AttributeError` in the child process
106+
trying to locate the *f* function in the ``__main__`` module.
107107

108108

109109
.. _multiprocessing-start-methods:
@@ -1713,7 +1713,10 @@ inherited by child processes.
17131713
Note that *lock* is a keyword only argument.
17141714

17151715
Note that an array of :data:`ctypes.c_char` has *value* and *raw*
1716-
attributes which allow one to use it to store and retrieve strings.
1716+
attributes which can both be used to store and retrieve byte strings.
1717+
While *raw* allows interaction with a :class:`bytes` object the full size of
1718+
the array, reading *value* will terminate after a null byte, like most
1719+
programming languages handle strings.
17171720

17181721

17191722
The :mod:`!multiprocessing.sharedctypes` module

pr-preview/pr-1226/_sources/library/sched.rst.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ Scheduler Objects
119119
function passed to the constructor) for the next event, then execute it and so
120120
on until there are no more scheduled events.
121121

122-
If *blocking* is false executes the scheduled events due to expire soonest
123-
(if any) and then return the deadline of the next scheduled call in the
124-
scheduler (if any).
122+
If *blocking* is false, immediately executes all events in the queue which have
123+
a time value less than or equal to the current *timefunc* value (if any) and
124+
returns the difference between the current *timefunc* value and the time value
125+
of the next scheduled event in the scheduler's event queue. If the queue is
126+
empty, returns ``None``.
125127

126128
Either *action* or *delayfunc* can raise an exception. In either case, the
127129
scheduler will maintain a consistent state and propagate the exception. If an

pr-preview/pr-1226/_sources/library/urllib.request.rst.txt

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ AbstractBasicAuthHandler Objects
10551055
*headers* should be the error headers.
10561056

10571057
*host* is either an authority (e.g. ``"python.org"``) or a URL containing an
1058-
authority component (e.g. ``"http://python.org/"``). In either case, the
1058+
authority component (e.g. ``"https://python.org/"``). In either case, the
10591059
authority must not contain a userinfo component (so, ``"python.org"`` and
10601060
``"python.org:80"`` are fine, ``"joe:password@python.org"`` is not).
10611061

@@ -1251,10 +1251,14 @@ This example gets the python.org main page and displays the first 300 bytes of
12511251
it::
12521252

12531253
>>> import urllib.request
1254-
>>> with urllib.request.urlopen('http://www.python.org/') as f:
1255-
... print(f.read(300))
1256-
...
1257-
b'<!doctype html>\n<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 7]> <html class="no-js ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 8]> <html class="no-js ie8 lt-ie9">
1254+
>>> with urllib.request.urlopen('https://www.python.org/') as f:
1255+
... # The response may be compressed (for example, 'gzip').
1256+
... print(f.headers.get('Content-Encoding'))
1257+
... data = f.read()
1258+
... if f.headers.get('Content-Encoding') == 'gzip':
1259+
... import gzip
1260+
... data = gzip.decompress(data)
1261+
... print(data[:300].decode('utf-8', errors='replace'))
12581262

12591263
Note that urlopen returns a bytes object. This is because there is no way
12601264
for urlopen to automatically determine the encoding of the byte stream
@@ -1271,26 +1275,30 @@ For additional information, see the W3C document: https://www.w3.org/Internation
12711275
As the python.org website uses *utf-8* encoding as specified in its meta tag, we
12721276
will use the same for decoding the bytes object::
12731277

1274-
>>> with urllib.request.urlopen('http://www.python.org/') as f:
1275-
... print(f.read(100).decode('utf-8'))
1278+
>>> with urllib.request.urlopen('https://www.python.org/') as f:
1279+
... # Check for compression and decode appropriately.
1280+
... enc = f.headers.get('Content-Encoding')
1281+
... data = f.read()
1282+
... if enc == 'gzip':
1283+
... import gzip
1284+
... data = gzip.decompress(data)
1285+
... print(data[:100].decode('utf-8', errors='replace'))
12761286
...
1277-
<!doctype html>
1278-
<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->
1279-
<!-
12801287

12811288
It is also possible to achieve the same result without using the
12821289
:term:`context manager` approach::
12831290

12841291
>>> import urllib.request
1285-
>>> f = urllib.request.urlopen('http://www.python.org/')
1292+
>>> f = urllib.request.urlopen('https://www.python.org/')
12861293
>>> try:
1287-
... print(f.read(100).decode('utf-8'))
1294+
... enc = f.headers.get('Content-Encoding')
1295+
... data = f.read()
1296+
... if enc == 'gzip':
1297+
... import gzip
1298+
... data = gzip.decompress(data)
1299+
... print(data[:100].decode('utf-8', errors='replace'))
12881300
... finally:
12891301
... f.close()
1290-
...
1291-
<!doctype html>
1292-
<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->
1293-
<!--
12941302

12951303
In the following example, we are sending a data-stream to the stdin of a CGI
12961304
and reading the data it returns to us. Note that this example will only work
@@ -1361,7 +1369,7 @@ Use the *headers* argument to the :class:`Request` constructor, or::
13611369

13621370
import urllib.request
13631371
req = urllib.request.Request('http://www.example.com/')
1364-
req.add_header('Referer', 'http://www.python.org/')
1372+
req.add_header('Referer', 'https://www.python.org/')
13651373
# Customize the default User-Agent header value:
13661374
req.add_header('User-Agent', 'urllib-example/0.1 (Contact: . . .)')
13671375
with urllib.request.urlopen(req) as f:
@@ -1390,7 +1398,7 @@ containing parameters::
13901398
>>> import urllib.request
13911399
>>> import urllib.parse
13921400
>>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
1393-
>>> url = "http://www.musi-cal.com/cgi-bin/query?%s" % params
1401+
>>> url = "https://www.python.org/?%s" % params
13941402
>>> with urllib.request.urlopen(url) as f:
13951403
... print(f.read().decode('utf-8'))
13961404
...
@@ -1402,7 +1410,7 @@ from urlencode is encoded to bytes before it is sent to urlopen as data::
14021410
>>> import urllib.parse
14031411
>>> data = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
14041412
>>> data = data.encode('ascii')
1405-
>>> with urllib.request.urlopen("http://requestb.in/xrbl82xr", data) as f:
1413+
>>> with urllib.request.urlopen("https://httpbin.org/post", data) as f:
14061414
... print(f.read().decode('utf-8'))
14071415
...
14081416

@@ -1412,15 +1420,15 @@ environment settings::
14121420
>>> import urllib.request
14131421
>>> proxies = {'http': 'http://proxy.example.com:8080/'}
14141422
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler(proxies))
1415-
>>> with opener.open("http://www.python.org") as f:
1423+
>>> with opener.open("https://www.python.org") as f:
14161424
... f.read().decode('utf-8')
14171425
...
14181426

14191427
The following example uses no proxies at all, overriding environment settings::
14201428

14211429
>>> import urllib.request
1422-
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler({}}))
1423-
>>> with opener.open("http://www.python.org/") as f:
1430+
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
1431+
>>> with opener.open("https://www.python.org/") as f:
14241432
... f.read().decode('utf-8')
14251433
...
14261434

@@ -1453,7 +1461,7 @@ some point in the future.
14531461
The following example illustrates the most common usage scenario::
14541462

14551463
>>> import urllib.request
1456-
>>> local_filename, headers = urllib.request.urlretrieve('http://python.org/')
1464+
>>> local_filename, headers = urllib.request.urlretrieve('https://python.org/')
14571465
>>> html = open(local_filename)
14581466
>>> html.close()
14591467

pr-preview/pr-1226/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h3>導航</h3>
356356
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
357357
<br>
358358
<br>
359-
最後更新於 5月 31, 2026 (00:46 UTC)。
359+
最後更新於 6月 01, 2026 (00:48 UTC)。
360360

361361
<a href="/bugs.html">發現 bug</a>
362362

pr-preview/pr-1226/bugs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
250250
</section>
251251
<section id="getting-started-contributing-to-python-yourself">
252252
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="連結到這個標頭"></a></h2>
253-
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
253+
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在 <a class="reference external" href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
254254
</section>
255255
</section>
256256

@@ -393,7 +393,7 @@ <h3>導航</h3>
393393
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
394394
<br>
395395
<br>
396-
最後更新於 5月 31, 2026 (00:46 UTC)。
396+
最後更新於 6月 01, 2026 (00:48 UTC)。
397397

398398
<a href="/bugs.html">發現 bug</a>
399399

pr-preview/pr-1226/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <h3>導航</h3>
365365
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
366366
<br>
367367
<br>
368-
最後更新於 5月 31, 2026 (00:46 UTC)。
368+
最後更新於 6月 01, 2026 (00:48 UTC)。
369369

370370
<a href="/bugs.html">發現 bug</a>
371371

0 commit comments

Comments
 (0)