Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c29c03a3
Commit
c29c03a3
authored
Feb 23, 2018
by
Cheryl Sabella
Committed by
Terry Jan Reedy
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32916: IDLE: Change `str` to `code` in pyparse (GH-5830)
Adjust tests and user modules to match.
parent
11a1493b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
102 deletions
+103
-102
Lib/idlelib/editor.py
Lib/idlelib/editor.py
+2
-2
Lib/idlelib/hyperparser.py
Lib/idlelib/hyperparser.py
+4
-4
Lib/idlelib/idle_test/test_pyparse.py
Lib/idlelib/idle_test/test_pyparse.py
+35
-35
Lib/idlelib/pyparse.py
Lib/idlelib/pyparse.py
+61
-61
Misc/NEWS.d/next/IDLE/2018-02-23-07-32-36.bpo-32916.4MsQ5F.rst
...NEWS.d/next/IDLE/2018-02-23-07-32-36.bpo-32916.4MsQ5F.rst
+1
-0
No files found.
Lib/idlelib/editor.py
View file @
c29c03a3
...
...
@@ -1302,7 +1302,7 @@ class EditorWindow(object):
startat
=
max
(
lno
-
context
,
1
)
startatindex
=
repr
(
startat
)
+
".0"
rawtext
=
text
.
get
(
startatindex
,
"insert"
)
y
.
set_
str
(
rawtext
)
y
.
set_
code
(
rawtext
)
bod
=
y
.
find_good_parse_start
(
self
.
context_use_ps1
,
self
.
_build_char_in_string_func
(
startatindex
))
...
...
@@ -1316,7 +1316,7 @@ class EditorWindow(object):
else
:
startatindex
=
"1.0"
rawtext
=
text
.
get
(
startatindex
,
"insert"
)
y
.
set_
str
(
rawtext
)
y
.
set_
code
(
rawtext
)
y
.
set_lo
(
0
)
c
=
y
.
get_continuation_type
()
...
...
Lib/idlelib/hyperparser.py
View file @
c29c03a3
...
...
@@ -44,7 +44,7 @@ class HyperParser:
# at end. We add a space so that index won't be at end
# of line, so that its status will be the same as the
# char before it, if should.
parser
.
set_
str
(
text
.
get
(
startatindex
,
stopatindex
)
+
'
\
n
'
)
parser
.
set_
code
(
text
.
get
(
startatindex
,
stopatindex
)
+
'
\
n
'
)
bod
=
parser
.
find_good_parse_start
(
editwin
.
_build_char_in_string_func
(
startatindex
))
if
bod
is
not
None
or
startat
==
1
:
...
...
@@ -60,12 +60,12 @@ class HyperParser:
# We add the newline because PyParse requires it. We add a
# space so that index won't be at end of line, so that its
# status will be the same as the char before it, if should.
parser
.
set_
str
(
text
.
get
(
startatindex
,
stopatindex
)
+
'
\
n
'
)
parser
.
set_
code
(
text
.
get
(
startatindex
,
stopatindex
)
+
'
\
n
'
)
parser
.
set_lo
(
0
)
# We want what the parser has, minus the last newline and space.
self
.
rawtext
=
parser
.
str
[:
-
2
]
# Parser.
str
apparently preserves the statement we are in, so
self
.
rawtext
=
parser
.
code
[:
-
2
]
# Parser.
code
apparently preserves the statement we are in, so
# that stopatindex can be used to synchronize the string with
# the text box indices.
self
.
stopatindex
=
stopatindex
...
...
Lib/idlelib/idle_test/test_pyparse.py
View file @
c29c03a3
...
...
@@ -62,32 +62,32 @@ class PyParseTest(unittest.TestCase):
self
.
assertEqual
(
self
.
parser
.
indentwidth
,
4
)
self
.
assertEqual
(
self
.
parser
.
tabwidth
,
4
)
def
test_set_
str
(
self
):
def
test_set_
code
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
# Not empty and doesn't end with newline.
with
self
.
assertRaises
(
AssertionError
):
set
str
(
'a'
)
set
code
(
'a'
)
tests
=
(
''
,
'a
\
n
'
)
for
string
in
tests
:
with
self
.
subTest
(
string
=
string
):
set
str
(
string
)
eq
(
p
.
str
,
string
)
set
code
(
string
)
eq
(
p
.
code
,
string
)
eq
(
p
.
study_level
,
0
)
def
test_find_good_parse_start
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
start
=
p
.
find_good_parse_start
# Split def across lines.
set
str
(
'"""This is a module docstring"""
\
n
'
set
code
(
'"""This is a module docstring"""
\
n
'
'class C():
\
n
'
' def __init__(self, a,
\
n
'
' b=True):
\
n
'
...
...
@@ -117,7 +117,7 @@ class PyParseTest(unittest.TestCase):
# Code without extra line break in def line - mostly returns the same
# values.
set
str
(
'"""This is a module docstring"""
\
n
'
set
code
(
'"""This is a module docstring"""
\
n
'
'class C():
\
n
'
' def __init__(self, a, b=True):
\
n
'
' pass
\
n
'
...
...
@@ -138,19 +138,19 @@ class PyParseTest(unittest.TestCase):
' pass
\
n
'
)
p
=
self
.
parser
p
.
set_
str
(
code
)
p
.
set_
code
(
code
)
# Previous character is not a newline.
with
self
.
assertRaises
(
AssertionError
):
p
.
set_lo
(
5
)
# A value of 0 doesn't change self.
str
.
# A value of 0 doesn't change self.
code
.
p
.
set_lo
(
0
)
self
.
assertEqual
(
p
.
str
,
code
)
self
.
assertEqual
(
p
.
code
,
code
)
# An index that is preceded by a newline.
p
.
set_lo
(
44
)
self
.
assertEqual
(
p
.
str
,
code
[
44
:])
self
.
assertEqual
(
p
.
code
,
code
[
44
:])
def
test_tran
(
self
):
self
.
assertEqual
(
'
\
t
a([{b}])b"c
\
'
d
\
n
'
.
translate
(
self
.
parser
.
_tran
),
...
...
@@ -159,7 +159,7 @@ class PyParseTest(unittest.TestCase):
def
test_study1
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
study
=
p
.
_study1
(
NONE
,
BACKSLASH
,
FIRST
,
NEXT
,
BRACKET
)
=
range
(
5
)
...
...
@@ -197,7 +197,7 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
# resets study_level
set
code
(
test
.
string
)
# resets study_level
study
()
eq
(
p
.
study_level
,
1
)
eq
(
p
.
goodlines
,
test
.
goodlines
)
...
...
@@ -209,7 +209,7 @@ class PyParseTest(unittest.TestCase):
def
test_get_continuation_type
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
gettype
=
p
.
get_continuation_type
(
NONE
,
BACKSLASH
,
FIRST
,
NEXT
,
BRACKET
)
=
range
(
5
)
...
...
@@ -224,13 +224,13 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
gettype
(),
test
.
continuation
)
def
test_study2
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
study
=
p
.
_study2
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'start'
,
'end'
,
'lastch'
,
...
...
@@ -276,7 +276,7 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
study
()
eq
(
p
.
study_level
,
2
)
eq
(
p
.
stmt_start
,
test
.
start
)
...
...
@@ -291,7 +291,7 @@ class PyParseTest(unittest.TestCase):
def
test_get_num_lines_in_stmt
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
getlines
=
p
.
get_num_lines_in_stmt
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'lines'
])
...
...
@@ -307,19 +307,19 @@ class PyParseTest(unittest.TestCase):
)
# Blank string doesn't have enough elements in goodlines.
set
str
(
''
)
set
code
(
''
)
with
self
.
assertRaises
(
IndexError
):
getlines
()
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
getlines
(),
test
.
lines
)
def
test_compute_bracket_indent
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
indent
=
p
.
compute_bracket_indent
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'spaces'
])
...
...
@@ -340,18 +340,18 @@ class PyParseTest(unittest.TestCase):
)
# Must be C_BRACKET continuation type.
set
str
(
'def function1(self, a, b):
\
n
'
)
set
code
(
'def function1(self, a, b):
\
n
'
)
with
self
.
assertRaises
(
AssertionError
):
indent
()
for
test
in
tests
:
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
indent
(),
test
.
spaces
)
def
test_compute_backslash_indent
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
indent
=
p
.
compute_backslash_indent
# Must be C_BACKSLASH continuation type.
...
...
@@ -361,7 +361,7 @@ class PyParseTest(unittest.TestCase):
)
for
string
in
errors
:
with
self
.
subTest
(
string
=
string
):
set
str
(
string
)
set
code
(
string
)
with
self
.
assertRaises
(
AssertionError
):
indent
()
...
...
@@ -384,13 +384,13 @@ class PyParseTest(unittest.TestCase):
)
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
indent
(),
test
.
spaces
)
def
test_get_base_indent_string
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
baseindent
=
p
.
get_base_indent_string
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'indent'
])
...
...
@@ -405,14 +405,14 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
baseindent
(),
test
.
indent
)
def
test_is_block_opener
(
self
):
yes
=
self
.
assertTrue
no
=
self
.
assertFalse
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
opener
=
p
.
is_block_opener
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'assert_'
])
...
...
@@ -433,14 +433,14 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
test
.
assert_
(
opener
())
def
test_is_block_closer
(
self
):
yes
=
self
.
assertTrue
no
=
self
.
assertFalse
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
closer
=
p
.
is_block_closer
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'assert_'
])
...
...
@@ -462,13 +462,13 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
test
.
assert_
(
closer
())
def
test_get_last_stmt_bracketing
(
self
):
eq
=
self
.
assertEqual
p
=
self
.
parser
set
str
=
p
.
set_str
set
code
=
p
.
set_code
bracketing
=
p
.
get_last_stmt_bracketing
TestInfo
=
namedtuple
(
'TestInfo'
,
[
'string'
,
'bracket'
])
...
...
@@ -489,7 +489,7 @@ class PyParseTest(unittest.TestCase):
for
test
in
tests
:
with
self
.
subTest
(
string
=
test
.
string
):
set
str
(
test
.
string
)
set
code
(
test
.
string
)
eq
(
bracketing
(),
test
.
bracket
)
...
...
Lib/idlelib/pyparse.py
View file @
c29c03a3
This diff is collapsed.
Click to expand it.
Misc/NEWS.d/next/IDLE/2018-02-23-07-32-36.bpo-32916.4MsQ5F.rst
0 → 100644
View file @
c29c03a3
Change ``str`` to ``code`` in pyparse.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment