]> granicus.if.org Git - python/commitdiff
bpo-35610: IDLE - Replace .context_use_ps1 with .prompt_last_line (GH-11307)
authorCheryl Sabella <cheryl.sabella@gmail.com>
Sun, 2 Jun 2019 18:56:47 +0000 (14:56 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Sun, 2 Jun 2019 18:56:47 +0000 (14:56 -0400)
Changes in bpo- 31858 made the less informative 'context_use_ps1' redundant.

Lib/idlelib/NEWS.txt
Lib/idlelib/editor.py
Lib/idlelib/hyperparser.py
Lib/idlelib/idle_test/test_autocomplete.py
Lib/idlelib/idle_test/test_hyperparser.py
Lib/idlelib/idle_test/test_parenmatch.py
Lib/idlelib/pyshell.py
Misc/NEWS.d/next/IDLE/2019-06-02-14-10-52.bpo-35610.0w_v6Y.rst [new file with mode: 0644]

index b260d4e5ef1bd82ef7870ac9466be6f1675b2c61..982af77672517c73aa4d6efdf90ee86f4533ac7c 100644 (file)
@@ -3,6 +3,9 @@ Released on 2019-10-20?
 ======================================
 
 
+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.
index 83260329640e1ad96d1275cfe4ed42fac4c5c2dc..89b7239a96ea0e82e9a29a8de2b4964ba65684f1 100644 (file)
@@ -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
index 7e7e0ae8024754632a570e24056dd7fef0374419..77baca782b3fdc07c89a93aaffde082fed2988d2 100644 (file)
@@ -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"
index 398cb359e0931fe33cafc9f183cba733e0c39946..6181b29ec250cc64c743b1495562f823a0d1fe93 100644 (file)
@@ -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):
index 8dbfc63779d380699bb09c3bece3db282920127c..343843c4166e97dcab123c4b9835341e15f65739 100644 (file)
@@ -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')
index f58819abf1121194a106dacfad4b5bc75c974d08..4a41d8433d548368d333451d69bdc734ac85cab4 100644 (file)
@@ -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):
index 2de42658b01cb8a3a681a0595909dee25e045b07..6e0707d68bb6edefe32c8f4c50d4ab35fcb7b297 100755 (executable)
@@ -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
diff --git a/Misc/NEWS.d/next/IDLE/2019-06-02-14-10-52.bpo-35610.0w_v6Y.rst b/Misc/NEWS.d/next/IDLE/2019-06-02-14-10-52.bpo-35610.0w_v6Y.rst
new file mode 100644 (file)
index 0000000..0042ab7
--- /dev/null
@@ -0,0 +1,2 @@
+Replace now redundant .context_use_ps1 with .prompt_last_line. This finishes
+change started in bpo-31858.