file -> open in stdlib patch

D

Daniel Nogradi

Hi list,

AFAIK using file( ) to open a file is deprecated in favor of open( )
and while grepping through the stdlib I noticed a couple of occurences
of file( ) in the latest revision. I made a patch for getting rid of
them; it passes all the tests. Although the change is almost trivial,
since this is my first patch maybe it's better if someone
knowledgeable takes a look at it before submitting it to SF.

Daniel



Index: Lib/site.py
===================================================================
--- Lib/site.py (revision 53548)
+++ Lib/site.py (working copy)
@@ -274,7 +274,7 @@
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
- fp = file(filename, "rU")
+ fp = open(filename, "rU")
data = fp.read()
fp.close()
break
Index: Lib/webbrowser.py
===================================================================
--- Lib/webbrowser.py (revision 53548)
+++ Lib/webbrowser.py (working copy)
@@ -216,7 +216,7 @@
cmdline = [self.name] + raise_opt + args

if remote or self.background:
- inout = file(os.devnull, "r+")
+ inout = open(os.devnull, "r+")
else:
# for TTY browsers, we need stdin/out
inout = None
@@ -340,7 +340,7 @@
else:
action = "openURL"

- devnull = file(os.devnull, "r+")
+ devnull = open(os.devnull, "r+")
# if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None)
Index: Lib/pstats.py
===================================================================
--- Lib/pstats.py (revision 53548)
+++ Lib/pstats.py (working copy)
@@ -173,7 +173,7 @@

def dump_stats(self, filename):
"""Write the profile data to a file we know how to load back."""
- f = file(filename, 'wb')
+ f = open(filename, 'wb')
try:
marshal.dump(self.stats, f)
finally:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top