Skip to content

Commit fe8cd1f

Browse files
Deploy preview for PR 1231 🛫
1 parent 34af0d5 commit fe8cd1f

591 files changed

Lines changed: 1916 additions & 1737 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-1231/_sources/c-api/lifecycle.rst.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object's life. An arrow from *A* to *B* indicates that event *B* can occur
1919
after event *A* has occurred, with the arrow's label indicating the condition
2020
that must be true for *B* to occur after *A*.
2121

22-
.. only:: html and not epub
22+
.. only:: builder_html
2323

2424
.. raw:: html
2525

@@ -50,20 +50,13 @@ that must be true for *B* to occur after *A*.
5050
})();
5151
</script>
5252
53-
.. only:: epub or not (html or latex)
53+
.. only:: not builder_html
5454
5555
.. image:: lifecycle.dot.svg
5656
:align: center
5757
:class: invert-in-dark-mode
5858
:alt: Diagram showing events in an object's life. Explained in detail below.
5959
60-
.. only:: latex
61-
62-
.. image:: lifecycle.dot.pdf
63-
:align: center
64-
:class: invert-in-dark-mode
65-
:alt: Diagram showing events in an object's life. Explained in detail below.
66-
6760
.. container::
6861
:name: life-events-graph-description
6962

pr-preview/pr-1231/_sources/library/http.server.rst.txt

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ handler. Code to create and run the server looks like this::
3939
This class builds on the :class:`~socketserver.TCPServer` class by storing
4040
the server address as instance variables named :attr:`server_name` and
4141
:attr:`server_port`. The server is accessible by the handler, typically
42-
through the handler's :attr:`server` instance variable.
42+
through the handler's :attr:`~socketserver.BaseRequestHandler.server`
43+
instance variable.
44+
45+
.. attribute:: server_name
46+
47+
The HTTP server's fully qualified domain name.
48+
49+
.. attribute:: server_port
50+
51+
The HTTP server's port number obtained from *server_address*.
52+
4353

4454
.. class:: ThreadingHTTPServer(server_address, RequestHandlerClass)
4555

@@ -60,7 +70,7 @@ handler. Code to create and run the server looks like this::
6070
object fails with a :exc:`RuntimeError`.
6171

6272
The *certfile* argument is the path to the SSL certificate chain file,
63-
and the *keyfile* is the path to file containing the private key.
73+
and the *keyfile* is the path to the file containing the private key.
6474

6575
A *password* can be specified for files protected and wrapped with PKCS#8,
6676
but beware that this could possibly expose hardcoded passwords in clear.
@@ -140,7 +150,7 @@ instantiation, of which this module provides three different variants:
140150

141151
.. attribute:: path
142152

143-
Contains the request path. If query component of the URL is present,
153+
Contains the request path. If the query component of the URL is present,
144154
then ``path`` includes the query. Using the terminology of :rfc:`3986`,
145155
``path`` here includes ``hier-part`` and the ``query``.
146156

@@ -190,7 +200,7 @@ instantiation, of which this module provides three different variants:
190200
Specifies a format string that should be used by :meth:`send_error` method
191201
for building an error response to the client. The string is filled by
192202
default with variables from :attr:`responses` based on the status code
193-
that passed to :meth:`send_error`.
203+
passed to :meth:`send_error`.
194204

195205
.. attribute:: error_content_type
196206

@@ -238,8 +248,8 @@ instantiation, of which this module provides three different variants:
238248
.. method:: handle_expect_100()
239249

240250
When an HTTP/1.1 conformant server receives an ``Expect: 100-continue``
241-
request header it responds back with a ``100 Continue`` followed by ``200
242-
OK`` headers.
251+
request header it responds with a ``100 Continue`` followed by ``200 OK``
252+
headers.
243253
This method can be overridden to raise an error if the server does not
244254
want the client to continue. For example, the server can choose to send ``417
245255
Expectation Failed`` as a response header and ``return False``.
@@ -295,8 +305,8 @@ instantiation, of which this module provides three different variants:
295305
.. method:: send_response_only(code, message=None)
296306

297307
Sends the response header only, used for the purposes when ``100
298-
Continue`` response is sent by the server to the client. The headers not
299-
buffered and sent directly the output stream.If the *message* is not
308+
Continue`` response is sent by the server to the client. The headers are
309+
not buffered and sent directly the output stream. If the *message* is not
300310
specified, the HTTP message corresponding the response *code* is sent.
301311

302312
This method does not reject *message* containing CRLF sequences.
@@ -338,7 +348,7 @@ instantiation, of which this module provides three different variants:
338348
to create custom error logging mechanisms. The *format* argument is a
339349
standard printf-style format string, where the additional arguments to
340350
:meth:`log_message` are applied as inputs to the formatting. The client
341-
ip address and current date and time are prefixed to every message logged.
351+
IP address and current date and time are prefixed to every message logged.
342352

343353
.. method:: version_string()
344354

@@ -390,6 +400,14 @@ instantiation, of which this module provides three different variants:
390400
This will be ``"SimpleHTTP/" + __version__``, where ``__version__`` is
391401
defined at the module level.
392402

403+
.. attribute:: index_pages
404+
405+
Specifies the filenames that are treated as directory index pages.
406+
407+
Defaults to ``("index.html", "index.htm")``.
408+
409+
.. versionadded:: 3.12
410+
393411
.. attribute:: extensions_map
394412

395413
A dictionary mapping suffixes into MIME types, contains custom overrides
@@ -413,8 +431,8 @@ instantiation, of which this module provides three different variants:
413431
The request is mapped to a local file by interpreting the request as a
414432
path relative to the current working directory.
415433

416-
If the request was mapped to a directory, the directory is checked for a
417-
file named ``index.html`` or ``index.htm`` (in that order). If found, the
434+
If the request was mapped to a directory, the directory is checked for
435+
an index page as specified by :attr:`index_pages`. If found, the
418436
file's contents are returned; otherwise a directory listing is generated
419437
by calling the :meth:`list_directory` method. This method uses
420438
:func:`os.listdir` to scan the directory, and returns a ``404`` error
@@ -441,9 +459,32 @@ instantiation, of which this module provides three different variants:
441459
.. versionchanged:: 3.7
442460
Support of the ``'If-Modified-Since'`` header.
443461

444-
The :class:`SimpleHTTPRequestHandler` class can be used in the following
445-
manner in order to create a very basic webserver serving files relative to
446-
the current directory::
462+
.. method:: list_directory(path)
463+
464+
Helper to list the contents of *path* when no index page is present.
465+
466+
This returns either a :term:`file-like object` (which must be closed
467+
by the caller) or ``None`` to indicate an error, in which case the
468+
caller has nothing further to do. In either case, the headers are sent.
469+
470+
.. method:: guess_type(path)
471+
472+
Guess the type of the file at the given *path*.
473+
474+
This returns a string of the form ``type/subtype``, usable for
475+
a MIME Content-type header.
476+
477+
The default implementation looks the file's extension up in
478+
:attr:`extensions_map`, falling back to
479+
:func:`mimetypes.guess_file_type` and then to
480+
``'application/octet-stream'``.
481+
482+
.. versionchanged:: 3.13
483+
Add :func:`mimetypes.guess_file_type` as a fallback.
484+
485+
486+
The :class:`SimpleHTTPRequestHandler` class can be used to create a very basic
487+
webserver serving files relative to the current directory as follows::
447488

448489
import http.server
449490
import socketserver
@@ -459,7 +500,7 @@ the current directory::
459500

460501
:class:`SimpleHTTPRequestHandler` can also be subclassed to enhance behavior,
461502
such as using different index file names by overriding the class attribute
462-
:attr:`index_pages`.
503+
:attr:`~SimpleHTTPRequestHandler.index_pages`.
463504

464505

465506
.. class:: CGIHTTPRequestHandler(request, client_address, server)
@@ -480,7 +521,9 @@ such as using different index file names by overriding the class attribute
480521
the other common server configuration is to treat special extensions as
481522
denoting CGI scripts.
482523

483-
The :func:`do_GET` and :func:`do_HEAD` functions are modified to run CGI scripts
524+
The :func:`~SimpleHTTPRequestHandler.do_GET` and
525+
:func:`~SimpleHTTPRequestHandler.do_HEAD` functions
526+
are modified to run CGI scripts
484527
and serve the output, instead of serving files, if the request leads to
485528
somewhere below the ``cgi_directories`` path.
486529

@@ -637,13 +680,13 @@ Security considerations
637680
.. index:: pair: http.server; security
638681

639682
:class:`SimpleHTTPRequestHandler` will follow symbolic links when handling
640-
requests, this makes it possible for files outside of the specified directory
683+
requests which makes it possible for files outside of the specified directory
641684
to be served.
642685

643686
Methods :meth:`BaseHTTPRequestHandler.send_header` and
644687
:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input
645688
and do not perform input validation such as checking for the presence of CRLF
646-
sequences. Untrusted input may result in HTTP Header injection attacks.
689+
sequences. Untrusted input may result in HTTP header injection attacks.
647690

648691
Earlier versions of Python did not scrub control characters from the
649692
log messages emitted to stderr from ``python -m http.server`` or the

pr-preview/pr-1231/_sources/library/imaplib.rst.txt

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and
2525
:class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and
2626
implement a large subset of the IMAP4rev1 client protocol as defined in
27-
:rfc:`2060`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
27+
:rfc:`3501`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
2828
note that the ``STATUS`` command is not supported in IMAP4.
2929

3030
.. include:: ../includes/wasm-notavail.rst
@@ -135,21 +135,23 @@ The second subclass allows for connections created by a child process:
135135
The following utility functions are defined:
136136

137137

138-
.. function:: Internaldate2tuple(datestr)
138+
.. function:: Internaldate2tuple(resp)
139139

140-
Parse an IMAP4 ``INTERNALDATE`` string and return corresponding local
141-
time. The return value is a :class:`time.struct_time` tuple or
142-
``None`` if the string has wrong format.
140+
Parse a :term:`bytes-like object` containing an IMAP4 ``INTERNALDATE``
141+
response and return the corresponding local time. The return value is a
142+
:class:`time.struct_time` tuple or ``None`` if the input has wrong format.
143143

144144
.. function:: Int2AP(num)
145145

146146
Converts an integer into a bytes representation using characters from the set
147147
[``A`` .. ``P``].
148148

149149

150-
.. function:: ParseFlags(flagstr)
150+
.. function:: ParseFlags(resp)
151151

152-
Converts an IMAP4 ``FLAGS`` response to a tuple of individual flags.
152+
Converts a :term:`bytes-like object` containing an IMAP4 ``FLAGS`` response
153+
to a tuple of individual flags as :class:`bytes`. The return value is an
154+
empty tuple if the input has wrong format.
153155

154156

155157
.. function:: Time2Internaldate(date_time)
@@ -194,6 +196,9 @@ enclosed with either parentheses or double quotes) each string is quoted.
194196
However, the *password* argument to the ``LOGIN`` command is always quoted. If
195197
you want to avoid having an argument string quoted (eg: the *flags* argument to
196198
``STORE``) then enclose the string in parentheses (eg: ``r'(\Deleted)'``).
199+
In general, pass arguments unquoted and let the module quote them as needed.
200+
An argument that is already enclosed in double quotes is left unchanged,
201+
so that code which quotes arguments itself keeps working.
197202

198203
Most commands return a tuple: ``(type, [data, ...])`` where *type* is usually
199204
``'OK'`` or ``'NO'``, and *data* is either the text from the command response,
@@ -214,6 +219,11 @@ An :class:`IMAP4` instance has the following methods:
214219

215220
Append *message* to named mailbox.
216221

222+
*flags* may be ``None`` or a string of IMAP flag tokens. Multiple
223+
flags are separated by spaces, for example ``r'\Seen \Answered'``.
224+
If *flags* is not already enclosed in parentheses, parentheses are
225+
added automatically.
226+
217227

218228
.. method:: IMAP4.authenticate(mechanism, authobject)
219229

@@ -402,7 +412,7 @@ An :class:`IMAP4` instance has the following methods:
402412
.. versionadded:: 3.14
403413

404414

405-
.. method:: IMAP4.list([directory[, pattern]])
415+
.. method:: IMAP4.list(directory='', pattern='*')
406416

407417
List mailbox names in *directory* matching *pattern*. *directory* defaults to
408418
the top-level mail folder, and *pattern* defaults to match anything. Returned
@@ -432,7 +442,7 @@ An :class:`IMAP4` instance has the following methods:
432442
The method no longer ignores silently arbitrary exceptions.
433443

434444

435-
.. method:: IMAP4.lsub(directory='""', pattern='*')
445+
.. method:: IMAP4.lsub(directory='', pattern='*')
436446

437447
List subscribed mailbox names in directory matching pattern. *directory*
438448
defaults to the top level directory and *pattern* defaults to match any mailbox.
@@ -619,7 +629,7 @@ An :class:`IMAP4` instance has the following methods:
619629
.. method:: IMAP4.store(message_set, command, flag_list)
620630

621631
Alters flag dispositions for messages in mailbox. *command* is specified by
622-
section 6.4.6 of :rfc:`2060` as being one of "FLAGS", "+FLAGS", or "-FLAGS",
632+
section 6.4.6 of :rfc:`3501` as being one of "FLAGS", "+FLAGS", or "-FLAGS",
623633
optionally with a suffix of ".SILENT".
624634

625635
For example, to set the delete flag on all messages::
@@ -633,11 +643,11 @@ An :class:`IMAP4` instance has the following methods:
633643

634644
Creating flags containing ']' (for example: "[test]") violates
635645
:rfc:`3501` (the IMAP protocol). However, imaplib has historically
636-
allowed creation of such tags, and popular IMAP servers, such as Gmail,
646+
allowed creation of such flags, and popular IMAP servers, such as Gmail,
637647
accept and produce such flags. There are non-Python programs which also
638-
create such tags. Although it is an RFC violation and IMAP clients and
648+
create such flags. Although it is an RFC violation and IMAP clients and
639649
servers are supposed to be strict, imaplib still continues to allow
640-
such tags to be created for backward compatibility reasons, and as of
650+
such flags to be created for backward compatibility reasons, and as of
641651
Python 3.6, handles them if they are sent from the server, since this
642652
improves real-world compatibility.
643653

pr-preview/pr-1231/_sources/library/re.rst.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,9 @@ The special characters are:
512512
*name* exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is
513513
optional and can be omitted. For example,
514514
``(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)`` is a poor email matching pattern, which
515-
will match with ``'<user@host.com>'`` as well as ``'user@host.com'``, but
516-
not with ``'<user@host.com'`` nor ``'user@host.com>'``.
515+
matches ``'<user@host.com>'`` as well as ``'user@host.com'``, but does not
516+
match ``'<user@host.com'`` nor ``'user@host.com>'`` in their entirety
517+
(:func:`re.search` finds only ``'user@host.com'`` in the former).
517518

518519
.. versionchanged:: 3.12
519520
Group *id* can only contain ASCII digits.

pr-preview/pr-1231/_sources/library/tkinter.rst.txt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ method on it, and to change its value you call the :meth:`!set` method.
658658
If you follow this protocol, the widget will always track the value of the
659659
variable, with no further intervention on your part.
660660

661+
Keep a reference to the variable for as long as a widget uses it, for example
662+
by storing it as an attribute (see :class:`Variable`).
663+
661664
For example::
662665

663666
import tkinter as tk
@@ -736,6 +739,8 @@ Here are some examples of typical usage::
736739
myapp.mainloop()
737740

738741

742+
.. _Tk-option-data-types:
743+
739744
Tk option data types
740745
^^^^^^^^^^^^^^^^^^^^
741746

@@ -769,12 +774,16 @@ color
769774
represent any legal hex digit. See page 160 of Ousterhout's book for details.
770775

771776
cursor
772-
The standard X cursor names from :file:`cursorfont.h` can be used, without the
773-
``XC_`` prefix. For example to get a hand cursor (``XC_hand2``), use the
774-
string ``"hand2"``. You can also specify a bitmap and mask file of your own.
777+
The name of the mouse cursor to display while the pointer is over the widget.
778+
Tk provides a portable set of cursor names available on all platforms
779+
(for example ``"arrow"``, ``"watch"``, ``"cross"``, or ``"hand2"``);
780+
the standard X cursor names from :file:`cursorfont.h` may also be used,
781+
without the ``XC_`` prefix (so ``XC_hand2`` becomes ``"hand2"``).
782+
The full list of names, including the platform-specific ones,
783+
is given in the :manpage:`cursors(3tk)` manual page.
784+
You can also specify a bitmap and mask file of your own.
775785
On Windows a cursor file (:file:`.cur` or :file:`.ani`) may be used directly,
776786
giving its path preceded with an ``@``, as in ``"@C:/cursors/bart.ani"``.
777-
See page 179 of Ousterhout's book.
778787

779788
distance
780789
Screen distances can be specified in either pixels or absolute distances.
@@ -1991,6 +2000,7 @@ Base and mixin classes
19912000

19922001
Return the geometry of the widget, in the form ``widthxheight+x+y``.
19932002
All dimensions are in pixels.
2003+
An offset can be negative; see :meth:`~Wm.geometry`.
19942004

19952005
.. method:: winfo_height()
19962006

@@ -2451,6 +2461,8 @@ Base and mixin classes
24512461
*width* and *height* are in pixels (or grid units for a gridded window);
24522462
a position preceded by ``+`` is measured from the left or top edge of the
24532463
screen and one preceded by ``-`` from the right or bottom edge.
2464+
An offset can be negative, as in ``'200x100+-9+-8'``, when the window
2465+
edge is positioned beyond the corresponding screen edge.
24542466
An empty string cancels any user-specified geometry, letting the window
24552467
revert to its natural size.
24562468
With no argument, return the current geometry as a string of the form
@@ -5658,6 +5670,14 @@ Variable classes
56585670
:class:`StringVar`, :class:`IntVar`, :class:`DoubleVar` or
56595671
:class:`BooleanVar` -- rather than :class:`!Variable` directly.
56605672

5673+
.. note::
5674+
5675+
When a :class:`!Variable` is garbage collected, its Tcl variable is unset.
5676+
Keep a reference to it for as long as a widget is linked to it, for example
5677+
by storing it as an attribute rather than in a local variable.
5678+
Otherwise Tk recreates the Tcl variable to keep the widget working, but it
5679+
is never unset again, leaking one Tcl variable per dropped wrapper.
5680+
56615681
.. versionchanged:: 3.10
56625682
Two variables now compare equal (``==``) only when they have the same
56635683
name, are of the same class, and belong to the same Tcl interpreter.

0 commit comments

Comments
 (0)