Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51365fb

Browse files
Merge branch 'master' into disable-wchar-cache
2 parents 0da4146 + 3cbade7 commit 51365fb

131 files changed

Lines changed: 1367 additions & 760 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.

Doc/library/copy.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ The latter is called to implement the deep copy operation; it is passed one
8686
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
8787
to make a deep copy of a component, it should call the :func:`deepcopy` function
8888
with the component as first argument and the memo dictionary as second argument.
89+
The memo dictionary should be treated as an opaque object.
8990

9091

9192
.. seealso::

Doc/library/dataclasses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using :pep:`526` type annotations. For example this code::
2323

2424
@dataclass
2525
class InventoryItem:
26-
'''Class for keeping track of an item in inventory.'''
26+
"""Class for keeping track of an item in inventory."""
2727
name: str
2828
unit_price: float
2929
quantity_on_hand: int = 0

Doc/library/enum.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ The *type* of an enumeration member is the enumeration it belongs to::
113113
<enum 'Color'>
114114
>>> isinstance(Color.GREEN, Color)
115115
True
116-
>>>
117116

118117
Enum members also have a property that contains just their item name::
119118

Doc/library/functions.rst

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,38 @@ Built-in Functions
77
The Python interpreter has a number of functions and types built into it that
88
are always available. They are listed here in alphabetical order.
99

10-
=================== ================= ================== ================== ====================
11-
.. .. Built-in Functions .. ..
12-
=================== ================= ================== ================== ====================
13-
:func:`abs` :func:`delattr` :func:`hash` |func-memoryview|_ |func-set|_
14-
:func:`all` |func-dict|_ :func:`help` :func:`min` :func:`setattr`
15-
:func:`any` :func:`dir` :func:`hex` :func:`next` :func:`slice`
16-
:func:`ascii` :func:`divmod` :func:`id` :func:`object` :func:`sorted`
17-
:func:`bin` :func:`enumerate` :func:`input` :func:`oct` :func:`staticmethod`
18-
:func:`bool` :func:`eval` :func:`int` :func:`open` |func-str|_
19-
:func:`breakpoint` :func:`exec` :func:`isinstance` :func:`ord` :func:`sum`
20-
|func-bytearray|_ :func:`filter` :func:`issubclass` :func:`pow` :func:`super`
21-
|func-bytes|_ :func:`float` :func:`iter` :func:`print` |func-tuple|_
22-
:func:`callable` :func:`format` :func:`len` :func:`property` :func:`type`
23-
:func:`chr` |func-frozenset|_ |func-list|_ |func-range|_ :func:`vars`
24-
:func:`classmethod` :func:`getattr` :func:`locals` :func:`repr` :func:`zip`
25-
:func:`compile` :func:`globals` :func:`map` :func:`reversed` :func:`__import__`
26-
:func:`complex` :func:`hasattr` :func:`max` :func:`round`
27-
=================== ================= ================== ================== ====================
10+
+---------------------------------------------------------------------------------------------------+
11+
| Built-in Functions |
12+
+=========================+=======================+=======================+=========================+
13+
| | **A** | | **E** | | **L** | | **R** |
14+
| | :func:`abs` | | :func:`enumerate` | | :func:`len` | | |func-range|_ |
15+
| | :func:`all` | | :func:`eval` | | |func-list|_ | | :func:`repr` |
16+
| | :func:`any` | | :func:`exec` | | :func:`locals` | | :func:`reversed` |
17+
| | :func:`ascii` | | | | | | :func:`round` |
18+
| | | | **F** | | **M** | | |
19+
| | **B** | | :func:`filter` | | :func:`map` | | **S** |
20+
| | :func:`bin` | | :func:`float` | | :func:`max` | | |func-set|_ |
21+
| | :func:`bool` | | :func:`format` | | |func-memoryview|_ | | :func:`setattr` |
22+
| | :func:`breakpoint` | | |func-frozenset|_ | | :func:`min` | | :func:`slice` |
23+
| | |func-bytearray|_ | | | | | | :func:`sorted` |
24+
| | |func-bytes|_ | | **G** | | **N** | | :func:`staticmethod` |
25+
| | | | :func:`getattr` | | :func:`next` | | |func-str|_ |
26+
| | **C** | | :func:`globals` | | | | :func:`sum` |
27+
| | :func:`callable` | | | | **O** | | :func:`super` |
28+
| | :func:`chr` | | **H** | | :func:`object` | | |
29+
| | :func:`classmethod` | | :func:`hasattr` | | :func:`oct` | | **T** |
30+
| | :func:`compile` | | :func:`hash` | | :func:`open` | | |func-tuple|_ |
31+
| | :func:`complex` | | :func:`help` | | :func:`ord` | | :func:`type` |
32+
| | | | :func:`hex` | | | | |
33+
| | **D** | | | | **P** | | **V** |
34+
| | :func:`delattr` | | **I** | | :func:`pow` | | :func:`vars` |
35+
| | |func-dict|_ | | :func:`id` | | :func:`print` | | |
36+
| | :func:`dir` | | :func:`input` | | :func:`property` | | **Z** |
37+
| | :func:`divmod` | | :func:`int` | | | | :func:`zip` |
38+
| | | | :func:`isinstance` | | | | |
39+
| | | | :func:`issubclass` | | | | **_** |
40+
| | | | :func:`iter` | | | | :func:`__import__` |
41+
+-------------------------+-----------------------+-----------------------+-------------------------+
2842

2943
.. using :func:`dict` would create a link to another page, so local targets are
3044
used, with replacement texts to make the output in the table consistent

Doc/library/idle.rst

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Go to Line
147147
Clear any selection and update the line and column status.
148148

149149
Show Completions
150-
Open a scrollable list allowing selection of keywords and attributes. See
150+
Open a scrollable list allowing selection of existing names. See
151151
:ref:`Completions <completions>` in the Editing and navigation section below.
152152

153153
Expand Word
@@ -469,52 +469,58 @@ are restricted to four spaces due to Tcl/Tk limitations.
469469
See also the indent/dedent region commands on the
470470
:ref:`Format menu <format-menu>`.
471471

472-
473472
.. _completions:
474473

475474
Completions
476475
^^^^^^^^^^^
477476

478-
Completions are supplied for functions, classes, and attributes of classes,
479-
both built-in and user-defined. Completions are also provided for
480-
filenames.
481-
482-
The AutoCompleteWindow (ACW) will open after a predefined delay (default is
483-
two seconds) after a '.' or (in a string) an os.sep is typed. If after one
484-
of those characters (plus zero or more other characters) a tab is typed
485-
the ACW will open immediately if a possible continuation is found.
486-
487-
If there is only one possible completion for the characters entered, a
488-
:kbd:`Tab` will supply that completion without opening the ACW.
489-
490-
'Show Completions' will force open a completions window, by default the
491-
:kbd:`C-space` will open a completions window. In an empty
492-
string, this will contain the files in the current directory. On a
493-
blank line, it will contain the built-in and user-defined functions and
494-
classes in the current namespaces, plus any modules imported. If some
495-
characters have been entered, the ACW will attempt to be more specific.
496-
497-
If a string of characters is typed, the ACW selection will jump to the
498-
entry most closely matching those characters. Entering a :kbd:`tab` will
499-
cause the longest non-ambiguous match to be entered in the Editor window or
500-
Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as
501-
will return or a double click. Cursor keys, Page Up/Down, mouse selection,
502-
and the scroll wheel all operate on the ACW.
503-
504-
"Hidden" attributes can be accessed by typing the beginning of hidden
505-
name after a '.', e.g. '_'. This allows access to modules with
506-
``__all__`` set, or to class-private attributes.
507-
508-
Completions and the 'Expand Word' facility can save a lot of typing!
509-
510-
Completions are currently limited to those in the namespaces. Names in
511-
an Editor window which are not via ``__main__`` and :data:`sys.modules` will
512-
not be found. Run the module once with your imports to correct this situation.
513-
Note that IDLE itself places quite a few modules in sys.modules, so
514-
much can be found by default, e.g. the re module.
515-
516-
If you don't like the ACW popping up unbidden, simply make the delay
517-
longer or disable the extension.
477+
Completions are supplied, when requested and available, for module
478+
names, attributes of classes or functions, or filenames. Each request
479+
method displays a completion box with existing names. (See tab
480+
completions below for an exception.) For any box, change the name
481+
being completed and the item highlighted in the box by
482+
typing and deleting characters; by hitting :kbd:`Up`, :kbd:`Down`,
483+
:kbd:`PageUp`, :kbd:`PageDown`, :kbd:`Home`, and :kbd:`End` keys;
484+
and by a single click within the box. Close the box with :kbd:`Escape`,
485+
:kbd:`Enter`, and double :kbd:`Tab` keys or clicks outside the box.
486+
A double click within the box selects and closes.
487+
488+
One way to open a box is to type a key character and wait for a
489+
predefined interval. This defaults to 2 seconds; customize it
490+
in the settings dialog. (To prevent auto popups, set the delay to a
491+
large number of milliseconds, such as 100000000.) For imported module
492+
names or class or function attributes, type '.'.
493+
For filenames in the root directory, type :data:`os.sep` or
494+
data:`os.altsep` immediately after an opening quote. (On Windows,
495+
one can specify a drive first.) Move into subdirectories by typing a
496+
directory name and a separator.
497+
498+
Instead of waiting, or after a box is closed, open a completion box
499+
immediately with Show Completions on the Edit menu. The default hot
500+
key is :kbd:`C-space`. If one types a prefix for the desired name
501+
before opening the box, the first match or near miss is made visible.
502+
The result is the same as if one enters a prefix
503+
after the box is displayed. Show Completions after a quote completes
504+
filenames in the current directory instead of a root directory.
505+
506+
Hitting :kbd:`Tab` after a prefix usually has the same effect as Show
507+
Completions. (With no prefix, it indents.) However, if there is only
508+
one match to the prefix, that match is immediately added to the editor
509+
text without opening a box.
510+
511+
Invoking 'Show Completions', or hitting :kbd:`Tab` after a prefix,
512+
outside of a string and without a preceding '.' opens a box with
513+
keywords, builtin names, and available module-level names.
514+
515+
When editing code in an editor (as oppose to Shell), increase the
516+
available module-level names by running your code
517+
and not restarting the Shell thereafter. This is especially useful
518+
after adding imports at the top of a file. This also increases
519+
possible attribute completions.
520+
521+
Completion boxes intially exclude names beginning with '_' or, for
522+
modules, not included in '__all__'. The hidden names can be accessed
523+
by typing '_' after '.', either before or after the box is opened.
518524

519525
.. _calltips:
520526

Doc/library/symtable.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ Examining Symbol Tables
156156

157157
Return ``True`` if the symbol is local to its block.
158158

159+
.. method:: is_annotated()
160+
161+
Return ``True`` if the symbol is annotated.
162+
159163
.. method:: is_free()
160164

161165
Return ``True`` if the symbol is referenced in its block, but not assigned

Doc/tools/extensions/pyspecific.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,39 @@ def run(self):
125125

126126
# Support for documenting audit event
127127

128+
def audit_events_purge(app, env, docname):
129+
"""This is to remove from env.all_audit_events old traces of removed
130+
documents.
131+
"""
132+
if not hasattr(env, 'all_audit_events'):
133+
return
134+
fresh_all_audit_events = {}
135+
for name, event in env.all_audit_events.items():
136+
event["source"] = [(d, t) for d, t in event["source"] if d != docname]
137+
if event["source"]:
138+
# Only keep audit_events that have at least one source.
139+
fresh_all_audit_events[name] = event
140+
env.all_audit_events = fresh_all_audit_events
141+
142+
143+
def audit_events_merge(app, env, docnames, other):
144+
"""In Sphinx parallel builds, this merges env.all_audit_events from
145+
subprocesses.
146+
147+
all_audit_events is a dict of names, with values like:
148+
{'source': [(docname, target), ...], 'args': args}
149+
"""
150+
if not hasattr(other, 'all_audit_events'):
151+
return
152+
if not hasattr(env, 'all_audit_events'):
153+
env.all_audit_events = {}
154+
for name, value in other.all_audit_events.items():
155+
if name in env.all_audit_events:
156+
env.all_audit_events[name]["source"].extend(value["source"])
157+
else:
158+
env.all_audit_events[name] = value
159+
160+
128161
class AuditEvent(Directive):
129162

130163
has_content = True
@@ -589,4 +622,6 @@ def setup(app):
589622
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
590623
app.add_directive('miscnews', MiscNews)
591624
app.connect('doctree-resolved', process_audit_events)
625+
app.connect('env-merge-info', audit_events_merge)
626+
app.connect('env-purge-doc', audit_events_purge)
592627
return {'version': '1.0', 'parallel_read_safe': True}

Doc/tutorial/classes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ accessible. "Directly accessible" here means that an unqualified reference to a
114114
name attempts to find the name in the namespace.
115115

116116
Although scopes are determined statically, they are used dynamically. At any
117-
time during execution, there are at least three nested scopes whose namespaces
118-
are directly accessible:
117+
time during execution, At any time during execution, there are 3 or 4 nested
118+
scopes whose namespaces are directly accessible:
119119

120120
* the innermost scope, which is searched first, contains the local names
121121
* the scopes of any enclosing functions, which are searched starting with the

Doc/tutorial/controlflow.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,10 @@ passed using *call by value* (where the *value* is always an object *reference*,
300300
not the value of the object). [#]_ When a function calls another function, a new
301301
local symbol table is created for that call.
302302

303-
A function definition introduces the function name in the current symbol table.
304-
The value of the function name has a type that is recognized by the interpreter
305-
as a user-defined function. This value can be assigned to another name which
306-
can then also be used as a function. This serves as a general renaming
307-
mechanism::
303+
A function definition associates the function name with the function object in
304+
the current symbol table. The interpreter recognizes the object pointed to by
305+
that name as a user-defined function. Other names can also point to that same
306+
function object and can also be used to access the function::
308307

309308
>>> fib
310309
<function fib at 10042ed0>

Doc/whatsnew/3.9.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ in nanoseconds. The benchmarks were measured on an
685685
running the macOS 64-bit builds found at
686686
`python.org <https://www.python.org/downloads/mac-osx/>`_.
687687

688+
* A number of Python builtins (:class:`range`, :class:`tuple`, :class:`set`, :class:`frozenset`, :class:`list`, :class:`dict`)
689+
are now sped up by using :pep:`590` vectorcall protocol.
690+
(Contributed by Dong-hee Na, Mark Shannon, Jeroen Demeyer and Petr Viktorin in :issue:`37207`.)
691+
688692

689693
Deprecated
690694
==========

0 commit comments

Comments
 (0)