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
95f34ab9
Commit
95f34ab9
authored
Aug 04, 2013
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18151: Replace remaining Idle 'open...close' pairs with 'with open'.
parent
c86d7e98
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
17 deletions
+10
-17
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+2
-5
Lib/idlelib/IOBinding.py
Lib/idlelib/IOBinding.py
+6
-9
Lib/idlelib/ScriptBinding.py
Lib/idlelib/ScriptBinding.py
+2
-3
No files found.
Lib/idlelib/EditorWindow.py
View file @
95f34ab9
...
@@ -882,12 +882,9 @@ class EditorWindow(object):
...
@@ -882,12 +882,9 @@ class EditorWindow(object):
"Load and update the recent files list and menus"
"Load and update the recent files list and menus"
rf_list
=
[]
rf_list
=
[]
if
os
.
path
.
exists
(
self
.
recent_files_path
):
if
os
.
path
.
exists
(
self
.
recent_files_path
):
rf_list_file
=
open
(
self
.
recent_files_path
,
'r'
,
with
open
(
self
.
recent_files_path
,
'r'
,
encoding
=
'utf_8'
,
errors
=
'replace'
)
encoding
=
'utf_8'
,
errors
=
'replace'
)
as
rf_list_file
:
try
:
rf_list
=
rf_list_file
.
readlines
()
rf_list
=
rf_list_file
.
readlines
()
finally
:
rf_list_file
.
close
()
if
new_file
:
if
new_file
:
new_file
=
os
.
path
.
abspath
(
new_file
)
+
'
\
n
'
new_file
=
os
.
path
.
abspath
(
new_file
)
+
'
\
n
'
if
new_file
in
rf_list
:
if
new_file
in
rf_list
:
...
...
Lib/idlelib/IOBinding.py
View file @
95f34ab9
...
@@ -208,11 +208,10 @@ class IOBinding:
...
@@ -208,11 +208,10 @@ class IOBinding:
try
:
try
:
# open the file in binary mode so that we can handle
# open the file in binary mode so that we can handle
# end-of-line convention ourselves.
# end-of-line convention ourselves.
f
=
open
(
filename
,
'rb'
)
with
open
(
filename
,
'rb'
)
as
f
:
two_lines
=
f
.
readline
()
+
f
.
readline
()
two_lines
=
f
.
readline
()
+
f
.
readline
()
f
.
seek
(
0
)
f
.
seek
(
0
)
bytes
=
f
.
read
()
bytes
=
f
.
read
()
f
.
close
()
except
OSError
as
msg
:
except
OSError
as
msg
:
tkMessageBox
.
showerror
(
"I/O Error"
,
str
(
msg
),
master
=
self
.
text
)
tkMessageBox
.
showerror
(
"I/O Error"
,
str
(
msg
),
master
=
self
.
text
)
return
False
return
False
...
@@ -373,10 +372,8 @@ class IOBinding:
...
@@ -373,10 +372,8 @@ class IOBinding:
text
=
text
.
replace
(
"
\
n
"
,
self
.
eol_convention
)
text
=
text
.
replace
(
"
\
n
"
,
self
.
eol_convention
)
chars
=
self
.
encode
(
text
)
chars
=
self
.
encode
(
text
)
try
:
try
:
f
=
open
(
filename
,
"wb"
)
with
open
(
filename
,
"wb"
)
as
f
:
f
.
write
(
chars
)
f
.
write
(
chars
)
f
.
flush
()
f
.
close
()
return
True
return
True
except
OSError
as
msg
:
except
OSError
as
msg
:
tkMessageBox
.
showerror
(
"I/O Error"
,
str
(
msg
),
tkMessageBox
.
showerror
(
"I/O Error"
,
str
(
msg
),
...
...
Lib/idlelib/ScriptBinding.py
View file @
95f34ab9
...
@@ -87,9 +87,8 @@ class ScriptBinding:
...
@@ -87,9 +87,8 @@ class ScriptBinding:
self
.
shell
=
shell
=
self
.
flist
.
open_shell
()
self
.
shell
=
shell
=
self
.
flist
.
open_shell
()
saved_stream
=
shell
.
get_warning_stream
()
saved_stream
=
shell
.
get_warning_stream
()
shell
.
set_warning_stream
(
shell
.
stderr
)
shell
.
set_warning_stream
(
shell
.
stderr
)
f
=
open
(
filename
,
'rb'
)
with
open
(
filename
,
'rb'
)
as
f
:
source
=
f
.
read
()
source
=
f
.
read
()
f
.
close
()
if
b'
\
r
'
in
source
:
if
b'
\
r
'
in
source
:
source
=
source
.
replace
(
b'
\
r
\
n
'
,
b'
\
n
'
)
source
=
source
.
replace
(
b'
\
r
\
n
'
,
b'
\
n
'
)
source
=
source
.
replace
(
b'
\
r
'
,
b'
\
n
'
)
source
=
source
.
replace
(
b'
\
r
'
,
b'
\
n
'
)
...
...
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