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
fa556bd7
Commit
fa556bd7
authored
Aug 04, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Plain Diff
Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog ended with '\'.
Patch by Roger Serwy.
parents
ba5010a6
5ad514d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
Lib/idlelib/ReplaceDialog.py
Lib/idlelib/ReplaceDialog.py
+26
-5
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/idlelib/ReplaceDialog.py
View file @
fa556bd7
...
@@ -2,6 +2,8 @@ from tkinter import *
...
@@ -2,6 +2,8 @@ from tkinter import *
from
idlelib
import
SearchEngine
from
idlelib
import
SearchEngine
from
idlelib.SearchDialogBase
import
SearchDialogBase
from
idlelib.SearchDialogBase
import
SearchDialogBase
import
re
def
replace
(
text
):
def
replace
(
text
):
root
=
text
.
_root
()
root
=
text
.
_root
()
...
@@ -11,6 +13,7 @@ def replace(text):
...
@@ -11,6 +13,7 @@ def replace(text):
dialog
=
engine
.
_replacedialog
dialog
=
engine
.
_replacedialog
dialog
.
open
(
text
)
dialog
.
open
(
text
)
class
ReplaceDialog
(
SearchDialogBase
):
class
ReplaceDialog
(
SearchDialogBase
):
title
=
"Replace Dialog"
title
=
"Replace Dialog"
...
@@ -55,8 +58,23 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -55,8 +58,23 @@ class ReplaceDialog(SearchDialogBase):
def
default_command
(
self
,
event
=
None
):
def
default_command
(
self
,
event
=
None
):
if
self
.
do_find
(
self
.
ok
):
if
self
.
do_find
(
self
.
ok
):
self
.
do_replace
()
if
self
.
do_replace
():
# Only find next match if replace succeeded.
self
.
do_find
(
0
)
# A bad re can cause a it to fail.
self
.
do_find
(
0
)
def
_replace_expand
(
self
,
m
,
repl
):
""" Helper function for expanding a regular expression
in the replace field, if needed. """
if
self
.
engine
.
isre
():
try
:
new
=
m
.
expand
(
repl
)
except
re
.
error
:
self
.
engine
.
report_error
(
repl
,
'Invalid Replace Expression'
)
new
=
None
else
:
new
=
repl
return
new
def
replace_all
(
self
,
event
=
None
):
def
replace_all
(
self
,
event
=
None
):
prog
=
self
.
engine
.
getprog
()
prog
=
self
.
engine
.
getprog
()
...
@@ -86,7 +104,9 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -86,7 +104,9 @@ class ReplaceDialog(SearchDialogBase):
line
,
m
=
res
line
,
m
=
res
chars
=
text
.
get
(
"%d.0"
%
line
,
"%d.0"
%
(
line
+
1
))
chars
=
text
.
get
(
"%d.0"
%
line
,
"%d.0"
%
(
line
+
1
))
orig
=
m
.
group
()
orig
=
m
.
group
()
new
=
m
.
expand
(
repl
)
new
=
self
.
_replace_expand
(
m
,
repl
)
if
new
is
None
:
break
i
,
j
=
m
.
span
()
i
,
j
=
m
.
span
()
first
=
"%d.%d"
%
(
line
,
i
)
first
=
"%d.%d"
%
(
line
,
i
)
last
=
"%d.%d"
%
(
line
,
j
)
last
=
"%d.%d"
%
(
line
,
j
)
...
@@ -103,7 +123,6 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -103,7 +123,6 @@ class ReplaceDialog(SearchDialogBase):
text
.
undo_block_stop
()
text
.
undo_block_stop
()
if
first
and
last
:
if
first
and
last
:
self
.
show_hit
(
first
,
last
)
self
.
show_hit
(
first
,
last
)
self
.
close
()
def
do_find
(
self
,
ok
=
0
):
def
do_find
(
self
,
ok
=
0
):
if
not
self
.
engine
.
getprog
():
if
not
self
.
engine
.
getprog
():
...
@@ -138,7 +157,9 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -138,7 +157,9 @@ class ReplaceDialog(SearchDialogBase):
m
=
prog
.
match
(
chars
,
col
)
m
=
prog
.
match
(
chars
,
col
)
if
not
prog
:
if
not
prog
:
return
False
return
False
new
=
m
.
expand
(
self
.
replvar
.
get
())
new
=
self
.
_replace_expand
(
m
,
self
.
replvar
.
get
())
if
new
is
None
:
return
False
text
.
mark_set
(
"insert"
,
first
)
text
.
mark_set
(
"insert"
,
first
)
text
.
undo_block_start
()
text
.
undo_block_start
()
if
m
.
group
():
if
m
.
group
():
...
...
Misc/NEWS
View file @
fa556bd7
...
@@ -77,6 +77,9 @@ Core and Builtins
...
@@ -77,6 +77,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
13052
:
Fix
IDLE
crashing
when
replace
string
in
Search
/
Replace
dialog
ended
with
'\'
.
Patch
by
Roger
Serwy
.
-
Issue
#
12655
:
Instead
of
requiring
a
custom
type
,
os
.
sched_getaffinity
and
-
Issue
#
12655
:
Instead
of
requiring
a
custom
type
,
os
.
sched_getaffinity
and
os
.
sched_setaffinity
now
use
regular
sets
of
integers
to
represent
the
CPUs
os
.
sched_setaffinity
now
use
regular
sets
of
integers
to
represent
the
CPUs
a
process
is
restricted
to
.
a
process
is
restricted
to
.
...
...
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