From 60d90ba2382e5462eee66d4b8171cacd9f0b5533 Mon Sep 17 00:00:00 2001
From: Seth Sims
Date: Fri, 10 Jul 2020 09:53:26 -0400
Subject: [PATCH 001/486] Added __next__ to _TemporaryFileWrapper
---
Lib/tempfile.py | 3 +++
Lib/test/test_tempfile.py | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index ba04be8f9058e1b..1d10e6a7d2d47da 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -500,6 +500,9 @@ def close(self):
"""
self._closer.close()
+ def __next__(self):
+ return next(self.file)
+
# iter() doesn't use __getattr__ to find the __iter__ method
def __iter__(self):
# Don't return iter(self.file), but yield from it to avoid closing
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 8ace883d74bb24d..400c9788d6df4e4 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -886,6 +886,22 @@ def make_file():
self.assertEqual(l, lines[i])
self.assertEqual(i, len(lines) - 1)
+ def test_next(self):
+ lines = [b'spam\n', b'eggs\n', b'beans\n']
+ def make_file():
+ f = tempfile.NamedTemporaryFile(mode='w+b')
+ f.write(b''.join(lines))
+ f.seek(0)
+ return f
+
+ with make_file() as fd:
+ for i, l in enumerate(lines):
+ self.assertEqual(l, next(fd))
+ self.assertEqual(i, len(lines) - 1)
+
+ with self.assertRaises(StopIteration) as context:
+ next(fd)
+
def test_creates_named(self):
# NamedTemporaryFile creates files with names
f = tempfile.NamedTemporaryFile()
From c614cdf41a44d401da36867adfb925b734740f2f Mon Sep 17 00:00:00 2001
From: Seth Sims
Date: Fri, 10 Jul 2020 10:09:11 -0400
Subject: [PATCH 002/486] Fixed spacing
---
Lib/tempfile.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 1d10e6a7d2d47da..1aa79bcb8a2a510 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -501,7 +501,7 @@ def close(self):
self._closer.close()
def __next__(self):
- return next(self.file)
+ return next(self.file)
# iter() doesn't use __getattr__ to find the __iter__ method
def __iter__(self):
From 937694ae6ca87dc1343ab1e84fdfe5bbb6c0b5eb Mon Sep 17 00:00:00 2001
From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com>
Date: Fri, 10 Jul 2020 14:33:53 +0000
Subject: [PATCH 003/486] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by?=
=?UTF-8?q?=20blurb=5Fit.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../NEWS.d/next/Library/2020-07-10-14-33-52.bpo-41270.pjUqyd.rst | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Misc/NEWS.d/next/Library/2020-07-10-14-33-52.bpo-41270.pjUqyd.rst
diff --git a/Misc/NEWS.d/next/Library/2020-07-10-14-33-52.bpo-41270.pjUqyd.rst b/Misc/NEWS.d/next/Library/2020-07-10-14-33-52.bpo-41270.pjUqyd.rst
new file mode 100644
index 000000000000000..11b51dd5b87c5d2
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-10-14-33-52.bpo-41270.pjUqyd.rst
@@ -0,0 +1 @@
+Made NamedTemporaryFile its own iterator to mimic file objects.
\ No newline at end of file
From 1a9ddc1eeb17a17808553e43b7575e0cf735cc84 Mon Sep 17 00:00:00 2001
From: Steve Dower
Date: Thu, 9 Jul 2020 18:52:43 +0100
Subject: [PATCH 004/486] bpo-41172: Fix check for compiler in test suite
(GH-21400)
---
Lib/test/support/__init__.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index f8f60fb6c27b912..b21978a61cd2f12 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1673,9 +1673,15 @@ def missing_compiler_executable(cmd_names=[]):
missing.
"""
- from distutils import ccompiler, sysconfig, spawn
+ from distutils import ccompiler, sysconfig, spawn, errors
compiler = ccompiler.new_compiler()
sysconfig.customize_compiler(compiler)
+ if compiler.compiler_type == "msvc":
+ # MSVC has no executables, so check whether initialization succeeds
+ try:
+ compiler.initialize()
+ except errors.DistutilsPlatformError:
+ return "msvc"
for name in compiler.executables:
if cmd_names and name not in cmd_names:
continue
From d9e44280e081377218be34eb04204f897480b4d3 Mon Sep 17 00:00:00 2001
From: E-Paine <63801254+E-Paine@users.noreply.github.com>
Date: Thu, 9 Jul 2020 21:18:34 +0200
Subject: [PATCH 005/486] Remove trailing >>> in enum docs (GH-21358)
The >>> as the last line serve no purpose and are not colored correctly by Sphinx.
---
Doc/library/enum.rst | 1 -
Misc/ACKS | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 4b4f5eb1944cc57..b327a0ad15f96c9 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -113,7 +113,6 @@ The *type* of an enumeration member is the enumeration it belongs to::
>>> isinstance(Color.GREEN, Color)
True
- >>>
Enum members also have a property that contains just their item name::
diff --git a/Misc/ACKS b/Misc/ACKS
index 641ef0cace00e2f..b585769608f4e98 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1266,6 +1266,7 @@ Richard Oudkerk
Russel Owen
Joonas Paalasmaa
Martin Packman
+Elisha Paine
Shriphani Palakodety
Julien Palard
Aviv Palivoda
From 138ccdd4c02a564d9928525ca6c4a15165e90703 Mon Sep 17 00:00:00 2001
From: Terry Jan Reedy
Date: Thu, 9 Jul 2020 18:08:33 -0400
Subject: [PATCH 006/486] bpo-37765: Add keywords to IDLE tab completions
(GH-15138)
Keywords are present in the main module tab completion lists generated by rlcompleter, which is used by REPLs on *nix. Add all keywords to IDLE's main module name list except those already added from builtins (True, False, and None) . This list may also be used by Show Completions on the Edit menu, and its hot key.
Rewrite Completions doc.
Co-authored-by: Cheryl Sabella
---
Doc/library/idle.rst | 90 ++++++++++---------
Lib/idlelib/NEWS.txt | 3 +
Lib/idlelib/autocomplete.py | 6 +-
Lib/idlelib/help.html | 85 ++++++++++--------
Lib/idlelib/idle_test/test_autocomplete.py | 7 +-
.../2020-07-07-18-44-30.bpo-37765.umc1o8.rst | 2 +
6 files changed, 110 insertions(+), 83 deletions(-)
create mode 100644 Misc/NEWS.d/next/IDLE/2020-07-07-18-44-30.bpo-37765.umc1o8.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index b1192e7bb465523..75b6fa3861b23d0 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -147,7 +147,7 @@ Go to Line
Clear any selection and update the line and column status.
Show Completions
- Open a scrollable list allowing selection of keywords and attributes. See
+ Open a scrollable list allowing selection of existing names. See
:ref:`Completions ` in the Editing and navigation section below.
Expand Word
@@ -469,52 +469,58 @@ are restricted to four spaces due to Tcl/Tk limitations.
See also the indent/dedent region commands on the
:ref:`Format menu `.
-
.. _completions:
Completions
^^^^^^^^^^^
-Completions are supplied for functions, classes, and attributes of classes,
-both built-in and user-defined. Completions are also provided for
-filenames.
-
-The AutoCompleteWindow (ACW) will open after a predefined delay (default is
-two seconds) after a '.' or (in a string) an os.sep is typed. If after one
-of those characters (plus zero or more other characters) a tab is typed
-the ACW will open immediately if a possible continuation is found.
-
-If there is only one possible completion for the characters entered, a
-:kbd:`Tab` will supply that completion without opening the ACW.
-
-'Show Completions' will force open a completions window, by default the
-:kbd:`C-space` will open a completions window. In an empty
-string, this will contain the files in the current directory. On a
-blank line, it will contain the built-in and user-defined functions and
-classes in the current namespaces, plus any modules imported. If some
-characters have been entered, the ACW will attempt to be more specific.
-
-If a string of characters is typed, the ACW selection will jump to the
-entry most closely matching those characters. Entering a :kbd:`tab` will
-cause the longest non-ambiguous match to be entered in the Editor window or
-Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as
-will return or a double click. Cursor keys, Page Up/Down, mouse selection,
-and the scroll wheel all operate on the ACW.
-
-"Hidden" attributes can be accessed by typing the beginning of hidden
-name after a '.', e.g. '_'. This allows access to modules with
-``__all__`` set, or to class-private attributes.
-
-Completions and the 'Expand Word' facility can save a lot of typing!
-
-Completions are currently limited to those in the namespaces. Names in
-an Editor window which are not via ``__main__`` and :data:`sys.modules` will
-not be found. Run the module once with your imports to correct this situation.
-Note that IDLE itself places quite a few modules in sys.modules, so
-much can be found by default, e.g. the re module.
-
-If you don't like the ACW popping up unbidden, simply make the delay
-longer or disable the extension.
+Completions are supplied, when requested and available, for module
+names, attributes of classes or functions, or filenames. Each request
+method displays a completion box with existing names. (See tab
+completions below for an exception.) For any box, change the name
+being completed and the item highlighted in the box by
+typing and deleting characters; by hitting :kbd:`Up`, :kbd:`Down`,
+:kbd:`PageUp`, :kbd:`PageDown`, :kbd:`Home`, and :kbd:`End` keys;
+and by a single click within the box. Close the box with :kbd:`Escape`,
+:kbd:`Enter`, and double :kbd:`Tab` keys or clicks outside the box.
+A double click within the box selects and closes.
+
+One way to open a box is to type a key character and wait for a
+predefined interval. This defaults to 2 seconds; customize it
+in the settings dialog. (To prevent auto popups, set the delay to a
+large number of milliseconds, such as 100000000.) For imported module
+names or class or function attributes, type '.'.
+For filenames in the root directory, type :data:`os.sep` or
+data:`os.altsep` immediately after an opening quote. (On Windows,
+one can specify a drive first.) Move into subdirectories by typing a
+directory name and a separator.
+
+Instead of waiting, or after a box is closed, open a completion box
+immediately with Show Completions on the Edit menu. The default hot
+key is :kbd:`C-space`. If one types a prefix for the desired name
+before opening the box, the first match or near miss is made visible.
+The result is the same as if one enters a prefix
+after the box is displayed. Show Completions after a quote completes
+filenames in the current directory instead of a root directory.
+
+Hitting :kbd:`Tab` after a prefix usually has the same effect as Show
+Completions. (With no prefix, it indents.) However, if there is only
+one match to the prefix, that match is immediately added to the editor
+text without opening a box.
+
+Invoking 'Show Completions', or hitting :kbd:`Tab` after a prefix,
+outside of a string and without a preceding '.' opens a box with
+keywords, builtin names, and available module-level names.
+
+When editing code in an editor (as oppose to Shell), increase the
+available module-level names by running your code
+and not restarting the Shell thereafter. This is especially useful
+after adding imports at the top of a file. This also increases
+possible attribute completions.
+
+Completion boxes intially exclude names beginning with '_' or, for
+modules, not included in '__all__'. The hidden names can be accessed
+by typing '_' after '.', either before or after the box is opened.
.. _calltips:
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 7ae29af0b30ce3f..1c5c03da86efc57 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,9 @@ Released on 2020-10-05?
======================================
+bpo-37765: Add keywords to module name completion list. Rewrite
+Completions section of IDLE doc.
+
bpo-41152: The encoding of ``stdin``, ``stdout`` and ``stderr`` in IDLE
is now always UTF-8.
diff --git a/Lib/idlelib/autocomplete.py b/Lib/idlelib/autocomplete.py
index c623d45a1534230..e1e9e17311eda1e 100644
--- a/Lib/idlelib/autocomplete.py
+++ b/Lib/idlelib/autocomplete.py
@@ -4,6 +4,7 @@
pop up a list of candidates.
"""
import __main__
+import keyword
import os
import string
import sys
@@ -171,10 +172,13 @@ def fetch_completions(self, what, mode):
(what, mode), {})
else:
if mode == ATTRS:
- if what == "":
+ if what == "": # Main module names.
namespace = {**__main__.__builtins__.__dict__,
**__main__.__dict__}
bigl = eval("dir()", namespace)
+ kwds = (s for s in keyword.kwlist
+ if s not in {'True', 'False', 'None'})
+ bigl.extend(kwds)
bigl.sort()
if "__all__" in bigl:
smalll = sorted(eval("__all__", namespace))
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 424c6b50f339e1c..81ce5100bb8ad5d 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -4,7 +4,7 @@
- IDLE — Python 3.9.0a4 documentation
+ IDLE — Python 3.10.0a0 documentation
@@ -17,7 +17,7 @@
@@ -71,7 +71,7 @@
Completions are supplied for functions, classes, and attributes of classes,
-both built-in and user-defined. Completions are also provided for
-filenames.
-
The AutoCompleteWindow (ACW) will open after a predefined delay (default is
-two seconds) after a ‘.’ or (in a string) an os.sep is typed. If after one
-of those characters (plus zero or more other characters) a tab is typed
-the ACW will open immediately if a possible continuation is found.
-
If there is only one possible completion for the characters entered, a
-Tab will supply that completion without opening the ACW.
-
‘Show Completions’ will force open a completions window, by default the
-C-space will open a completions window. In an empty
-string, this will contain the files in the current directory. On a
-blank line, it will contain the built-in and user-defined functions and
-classes in the current namespaces, plus any modules imported. If some
-characters have been entered, the ACW will attempt to be more specific.
-
If a string of characters is typed, the ACW selection will jump to the
-entry most closely matching those characters. Entering a tab will
-cause the longest non-ambiguous match to be entered in the Editor window or
-Shell. Two tab in a row will supply the current ACW selection, as
-will return or a double click. Cursor keys, Page Up/Down, mouse selection,
-and the scroll wheel all operate on the ACW.
-
“Hidden” attributes can be accessed by typing the beginning of hidden
-name after a ‘.’, e.g. ‘_’. This allows access to modules with
-__all__ set, or to class-private attributes.
-
Completions and the ‘Expand Word’ facility can save a lot of typing!
-
Completions are currently limited to those in the namespaces. Names in
-an Editor window which are not via __main__ and sys.modules will
-not be found. Run the module once with your imports to correct this situation.
-Note that IDLE itself places quite a few modules in sys.modules, so
-much can be found by default, e.g. the re module.
-
If you don’t like the ACW popping up unbidden, simply make the delay
-longer or disable the extension.
+
Completions are supplied, when requested and available, for module
+names, attributes of classes or functions, or filenames. Each request
+method displays a completion box with existing names. (See tab
+completions below for an exception.) For any box, change the name
+being completed and the item highlighted in the box by
+typing and deleting characters; by hitting Up, Down,
+PageUp, PageDown, Home, and End keys;
+and by a single click within the box. Close the box with Escape,
+Enter, and double Tab keys or clicks outside the box.
+A double click within the box selects and closes.
+
One way to open a box is to type a key character and wait for a
+predefined interval. This defaults to 2 seconds; customize it
+in the settings dialog. (To prevent auto popups, set the delay to a
+large number of milliseconds, such as 100000000.) For imported module
+names or class or function attributes, type ‘.’.
+For filenames in the root directory, type os.sep or
+data:os.altsep immediately after an opening quote. (On Windows,
+one can specify a drive first.) Move into subdirectories by typing a
+directory name and a separator.
+
Instead of waiting, or after a box is closed. open a completion box
+immediately with Show Completions on the Edit menu. The default hot
+key is C-space. If one types a prefix for the desired name
+before opening the box, the first match is displayed.
+The result is the same as if one enters a prefix
+after the box is displayed. Show Completions after a quote completes
+filenames in the current directory instead of a root directory.
+
Hitting Tab after a prefix usually has the same effect as Show
+Completions. (With no prefix, it indents.) However, if there is only
+one match to the prefix, that match is immediately added to the editor
+text without opening a box.
+
Invoking ‘Show Completions’, or hitting Tab after a prefix,
+outside of a string and without a preceding ‘.’ opens a box with
+keywords, builtin names, and available module-level names.
+
When editing code in an editor (as oppose to Shell), increase the
+available module-level names by running your code
+and not restarting the Shell thereafter. This is especially useful
+after adding imports at the top of a file. This also increases
+possible attribute completions.
+
Completion boxes intially exclude names beginning with ‘_’ or, for
+modules, not included in ‘__all__’. The hidden names can be accessed
+by typing ‘_’ after ‘.’, either before or after the box is opened.