[Python-checkins] bpo-32905: IDLE - remove unused code in pyparse module (GH-5807)
Miss Islington (bot)
webhook-mailer at python.org
Thu Feb 22 02:04:08 EST 2018
https://github.com/python/cpython/commit/d8e7b98b17cd2cc15b307f54a768c9ca31072b5f
commit: d8e7b98b17cd2cc15b307f54a768c9ca31072b5f
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-02-21T23:04:05-08:00
summary:
bpo-32905: IDLE - remove unused code in pyparse module (GH-5807)
dump is similar to print but less flexible. lastopenbracketpos is now always initialized in _study2, as was stmt_bracketing, so the class settings are not needed. get_last_open_bracket_pos is never called.
(cherry picked from commit 451d1edaf4d27c4e632d81246d308e8dd6ea945f)
Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>
files:
A Misc/NEWS.d/next/IDLE/2018-02-22-00-09-27.bpo-32905.VlXj0x.rst
M Lib/idlelib/idle_test/test_pyparse.py
M Lib/idlelib/pyparse.py
diff --git a/Lib/idlelib/idle_test/test_pyparse.py b/Lib/idlelib/idle_test/test_pyparse.py
index b84e9f843081..c45815b36ff2 100644
--- a/Lib/idlelib/idle_test/test_pyparse.py
+++ b/Lib/idlelib/idle_test/test_pyparse.py
@@ -1,4 +1,7 @@
-"""Unittest for idlelib.pyparse.py."""
+"""Unittest for idlelib.pyparse.py.
+
+Coverage: 97%
+"""
from collections import namedtuple
import unittest
@@ -272,8 +275,6 @@ def test_study2(self):
)
for test in tests:
- # There is a bug where this is carried forward from last item.
- p.lastopenbracketpos = None
with self.subTest(string=test.string):
setstr(test.string)
study()
@@ -464,33 +465,6 @@ def test_is_block_closer(self):
setstr(test.string)
test.assert_(closer())
- def test_get_last_open_bracket_pos(self):
- eq = self.assertEqual
- p = self.parser
- setstr = p.set_str
- openbracket = p.get_last_open_bracket_pos
-
- TestInfo = namedtuple('TestInfo', ['string', 'position'])
- tests = (
- TestInfo('', None),
- TestInfo('a\n', None),
- TestInfo('# (\n', None),
- TestInfo('""" (\n', None),
- TestInfo('a = (1 + 2) - 5 *\\\n', None),
- TestInfo('\n def function1(self, a,\n', 17),
- TestInfo('\n def function1(self, a, # End of line comment.\n', 17),
- TestInfo('{)(]\n', None),
- TestInfo('(((((((((()))))))\n', 2),
- TestInfo('(((((((((())\n)))\n))\n', 2),
- )
-
- for test in tests:
- # There is a bug where the value is carried forward from last item.
- p.lastopenbracketpos = None
- with self.subTest(string=test.string):
- setstr(test.string)
- eq(openbracket(), test.position)
-
def test_get_last_stmt_bracketing(self):
eq = self.assertEqual
p = self.parser
diff --git a/Lib/idlelib/pyparse.py b/Lib/idlelib/pyparse.py
index 72bd9e00c1e9..93607dc5bcd0 100644
--- a/Lib/idlelib/pyparse.py
+++ b/Lib/idlelib/pyparse.py
@@ -18,10 +18,6 @@
(C_NONE, C_BACKSLASH, C_STRING_FIRST_LINE,
C_STRING_NEXT_LINES, C_BRACKET) = range(5)
-if 0: # for throwaway debugging output
- def dump(*stuff):
- sys.__stdout__.write(" ".join(map(str, stuff)) + "\n")
-
# Find what looks like the start of a popular statement.
_synchre = re.compile(r"""
@@ -496,8 +492,7 @@ def _study2(self):
# end while p < q:
self.lastch = lastch
- if stack:
- self.lastopenbracketpos = stack[-1]
+ self.lastopenbracketpos = stack[-1] if stack else None
self.stmt_bracketing = tuple(bracketing)
def compute_bracket_indent(self):
@@ -620,22 +615,10 @@ def is_block_closer(self):
self._study2()
return _closere(self.str, self.stmt_start) is not None
- # XXX - is this used?
- lastopenbracketpos = None
-
- def get_last_open_bracket_pos(self):
- "Return index of last open bracket or None."
- self._study2()
- return self.lastopenbracketpos
-
- # XXX - is this used?
- stmt_bracketing = None
-
def get_last_stmt_bracketing(self):
- """Return a tuple of the structure of the bracketing of the last
- interesting statement.
+ """Return bracketing structure of the last interesting statement.
- Tuple is in the format defined in _study2().
+ The returned tuple is in the format defined in _study2().
"""
self._study2()
return self.stmt_bracketing
diff --git a/Misc/NEWS.d/next/IDLE/2018-02-22-00-09-27.bpo-32905.VlXj0x.rst b/Misc/NEWS.d/next/IDLE/2018-02-22-00-09-27.bpo-32905.VlXj0x.rst
new file mode 100644
index 000000000000..c9bedd98f2e0
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-02-22-00-09-27.bpo-32905.VlXj0x.rst
@@ -0,0 +1 @@
+Remove unused code in pyparse module.
More information about the Python-checkins
mailing list