diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-02 12:35:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-02 12:35:53 -0700 |
commit | b4e0bfd4778e142f037f50c19c4bb5bd123b4641 (patch) | |
tree | 6f356a18add8e64782b6b767446fa40a92a9060e /Lib | |
parent | c76add7afd68387aa2481d672e1c0d7e7b4c9afc (diff) | |
download | cpython-git-b4e0bfd4778e142f037f50c19c4bb5bd123b4641.tar.gz |
bpo-35610: IDLE - Replace .context_use_ps1 with .prompt_last_line (GH-11307)
Changes in bpo- 31858 made the less informative 'context_use_ps1' redundant.
(cherry picked from commit 6bdc4dee01788599808c7858e2fe9fdd72cf6792)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/idlelib/NEWS.txt | 3 | ||||
-rw-r--r-- | Lib/idlelib/editor.py | 7 | ||||
-rw-r--r-- | Lib/idlelib/hyperparser.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_autocomplete.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_hyperparser.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_parenmatch.py | 2 | ||||
-rwxr-xr-x | Lib/idlelib/pyshell.py | 2 |
7 files changed, 11 insertions, 13 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 808c236bb5..172fdc00d2 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,9 @@ Released on 2019-06-24? ====================================== +bpo-35610: Replace now redundant editor.context_use_ps1 with +.prompt_last_line. This finishes change started in bpo-31858. + bpo-32411: Stop sorting dict created with desired line order. bpo-37038: Make idlelib.run runnable; add test clause. diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 8326032964..89b7239a96 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -228,10 +228,6 @@ class EditorWindow(object): self.indentwidth = self.tabwidth self.set_notabs_indentwidth() - # If context_use_ps1 is true, parsing searches back for a ps1 line; - # else searches for a popular (if, def, ...) Python stmt. - self.context_use_ps1 = False - # When searching backwards for a reliable place to begin parsing, # first start num_context_lines[0] lines back, then # num_context_lines[1] lines back if that didn't work, and so on. @@ -1337,14 +1333,13 @@ class EditorWindow(object): # open/close first need to find the last stmt lno = index2line(text.index('insert')) y = pyparse.Parser(self.indentwidth, self.tabwidth) - if not self.context_use_ps1: + if not self.prompt_last_line: for context in self.num_context_lines: startat = max(lno - context, 1) startatindex = repr(startat) + ".0" rawtext = text.get(startatindex, "insert") y.set_code(rawtext) bod = y.find_good_parse_start( - self.context_use_ps1, self._build_char_in_string_func(startatindex)) if bod is not None or startat == 1: break diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py index 7e7e0ae802..77baca782b 100644 --- a/Lib/idlelib/hyperparser.py +++ b/Lib/idlelib/hyperparser.py @@ -35,7 +35,7 @@ class HyperParser: return int(float(index)) lno = index2line(text.index(index)) - if not editwin.context_use_ps1: + if not editwin.prompt_last_line: for context in editwin.num_context_lines: startat = max(lno - context, 1) startatindex = repr(startat) + ".0" diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index 398cb359e0..6181b29ec2 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -19,7 +19,7 @@ class DummyEditwin: self.text = text self.indentwidth = 8 self.tabwidth = 8 - self.context_use_ps1 = True + self.prompt_last_line = '>>>' # Currently not used by autocomplete. class AutoCompleteTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_hyperparser.py b/Lib/idlelib/idle_test/test_hyperparser.py index 8dbfc63779..343843c416 100644 --- a/Lib/idlelib/idle_test/test_hyperparser.py +++ b/Lib/idlelib/idle_test/test_hyperparser.py @@ -11,7 +11,7 @@ class DummyEditwin: self.text = text self.indentwidth = 8 self.tabwidth = 8 - self.context_use_ps1 = True + self.prompt_last_line = '>>>' self.num_context_lines = 50, 500, 1000 _build_char_in_string_func = EditorWindow._build_char_in_string_func @@ -53,7 +53,7 @@ class HyperParserTest(unittest.TestCase): def tearDown(self): self.text.delete('1.0', 'end') - self.editwin.context_use_ps1 = True + self.editwin.prompt_last_line = '>>>' def get_parser(self, index): """ @@ -71,7 +71,7 @@ class HyperParserTest(unittest.TestCase): self.assertIn('precedes', str(ve.exception)) # test without ps1 - self.editwin.context_use_ps1 = False + self.editwin.prompt_last_line = '' # number of lines lesser than 50 p = self.get_parser('end') diff --git a/Lib/idlelib/idle_test/test_parenmatch.py b/Lib/idlelib/idle_test/test_parenmatch.py index f58819abf1..4a41d8433d 100644 --- a/Lib/idlelib/idle_test/test_parenmatch.py +++ b/Lib/idlelib/idle_test/test_parenmatch.py @@ -17,7 +17,7 @@ class DummyEditwin: self.text = text self.indentwidth = 8 self.tabwidth = 8 - self.context_use_ps1 = True + self.prompt_last_line = '>>>' # Currently not used by parenmatch. class ParenMatchTest(unittest.TestCase): diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 2de42658b0..6e0707d68b 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -881,7 +881,7 @@ class PyShell(OutputWindow): self.usetabs = True # indentwidth must be 8 when using tabs. See note in EditorWindow: self.indentwidth = 8 - self.context_use_ps1 = True + self.sys_ps1 = sys.ps1 if hasattr(sys, 'ps1') else '>>> ' self.prompt_last_line = self.sys_ps1.split('\n')[-1] self.prompt = self.sys_ps1 # Changes when debug active |