features/pep-433: 963e450fc24f (original) (raw)
--- a/Lib/bz2.py +++ b/Lib/bz2.py @@ -95,7 +95,7 @@ class BZ2File(io.BufferedIOBase): raise ValueError("Invalid mode: %r" % (mode,)) if isinstance(filename, (str, bytes)):
self._fp = _builtin_open(filename, mode, cloexec=True)[](#l1.7)
self._fp = _builtin_open(filename, mode)[](#l1.8) self._closefp = True[](#l1.9) self._mode = mode_code[](#l1.10) elif hasattr(filename, "read") or hasattr(filename, "write"):[](#l1.11)
--- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -102,7 +102,7 @@ def compile_file(fullname, ddir=None, fo try: mtime = int(os.stat(fullname).st_mtime) expect = struct.pack('<4sl', imp.get_magic(), mtime)
with open(cfile, 'rb', cloexec=True) as chandle:[](#l2.7)
with open(cfile, 'rb') as chandle:[](#l2.8) actual = chandle.read(8)[](#l2.9) if expect == actual:[](#l2.10) return success[](#l2.11)
@@ -206,7 +206,7 @@ def main(): # if flist is provided then load it if args.flist: try:
with (sys.stdin if args.flist=='-' else open(args.flist, cloexec=True)) as f:[](#l2.16)
with (sys.stdin if args.flist=='-' else open(args.flist)) as f:[](#l2.17) for line in f:[](#l2.18) compile_dests.append(line.strip())[](#l2.19) except OSError:[](#l2.20)
--- a/Lib/dbm/dumb.py +++ b/Lib/dbm/dumb.py @@ -77,7 +77,7 @@ class _Database(collections.MutableMappi def _update(self): self._index = {} try:
f = _io.open(self._dirfile, 'r', encoding="Latin-1", cloexec=True)[](#l3.7)
f = _io.open(self._dirfile, 'r', encoding="Latin-1")[](#l3.8) except OSError:[](#l3.9) pass[](#l3.10) else:[](#l3.11)
@@ -108,7 +108,7 @@ class _Database(collections.MutableMappi except OSError: pass
f = self._io.open(self._dirfile, 'w', encoding="Latin-1", cloexec=True)[](#l3.16)
f = self._io.open(self._dirfile, 'w', encoding="Latin-1")[](#l3.17) self._chmod(self._dirfile)[](#l3.18) for key, pos_and_siz_pair in self._index.items():[](#l3.19) # Use Latin-1 since it has no qualms with any value in any[](#l3.20)
@@ -122,7 +122,7 @@ class _Database(collections.MutableMappi if isinstance(key, str): key = key.encode('utf-8') pos, siz = self._index[key] # may raise KeyError
f = _io.open(self._datfile, 'rb', cloexec=True)[](#l3.25)
f = _io.open(self._datfile, 'rb')[](#l3.26) f.seek(pos)[](#l3.27) dat = f.read(siz)[](#l3.28) f.close()[](#l3.29)
@@ -133,7 +133,7 @@ class _Database(collections.MutableMappi # to get to an aligned offset. Return pair # (starting offset of val, len(val)) def _addval(self, val):
f = _io.open(self._datfile, 'rb+', cloexec=True)[](#l3.34)
f = _io.open(self._datfile, 'rb+')[](#l3.35) f.seek(0, 2)[](#l3.36) pos = int(f.tell())[](#l3.37) npos = ((pos + _BLOCKSIZE - 1) // _BLOCKSIZE) * _BLOCKSIZE[](#l3.38)
@@ -148,7 +148,7 @@ class _Database(collections.MutableMappi # pos to hold val, without overwriting some other value. Return # pair (pos, len(val)). def _setval(self, pos, val):
f = _io.open(self._datfile, 'rb+', cloexec=True)[](#l3.43)
f = _io.open(self._datfile, 'rb+')[](#l3.44) f.seek(pos)[](#l3.45) f.write(val)[](#l3.46) f.close()[](#l3.47)
@@ -159,7 +159,7 @@ class _Database(collections.MutableMappi # the in-memory index dict, and append one to the directory file. def _addkey(self, key, pos_and_siz_pair): self._index[key] = pos_and_siz_pair
f = _io.open(self._dirfile, 'a', encoding="Latin-1", cloexec=True)[](#l3.52)
f = _io.open(self._dirfile, 'a', encoding="Latin-1")[](#l3.53) self._chmod(self._dirfile)[](#l3.54) f.write("%r, %r\n" % (key.decode("Latin-1"), pos_and_siz_pair))[](#l3.55) f.close()[](#l3.56)
--- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -222,7 +222,7 @@ def _load_testfile(filename, package, mo # get_data() opens files as 'rb', so one must do the equivalent # conversion as universal newlines would do. return file_contents.replace(os.linesep, '\n'), filename
--- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -67,7 +67,7 @@ def _sig(st): def _do_cmp(f1, f2): bufsize = BUFSIZE
- with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: while True: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize)
--- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -330,18 +330,18 @@ class FileInput: pass # The next few lines may raise OSError os.rename(self._filename, self._backupfilename)
self._file = open(self._backupfilename, self._mode, cloexec=True)[](#l6.7)
self._file = open(self._backupfilename, self._mode)[](#l6.8) try:[](#l6.9) perm = os.fstat(self._file.fileno()).st_mode[](#l6.10) except OSError:[](#l6.11)
self._output = open(self._filename, "w", cloexec=True)[](#l6.12)
self._output = open(self._filename, "w")[](#l6.13) else:[](#l6.14) mode = os.O_CREAT | os.O_WRONLY | os.O_TRUNC[](#l6.15) if hasattr(os, 'O_BINARY'):[](#l6.16) mode |= os.O_BINARY[](#l6.17)
fd = os.open(self._filename, mode, perm, cloexec=True)[](#l6.19)
self._output = os.fdopen(fd, "w", cloexec=False)[](#l6.20)
fd = os.open(self._filename, mode, perm)[](#l6.21)
self._output = os.fdopen(fd, "w")[](#l6.22) try:[](#l6.23) if hasattr(os, 'chmod'):[](#l6.24) os.chmod(self._filename, perm)[](#l6.25)
@@ -354,7 +354,7 @@ class FileInput: if self._openhook: self._file = self._openhook(self._filename, self._mode) else:
self._file = open(self._filename, self._mode, cloexec=True)[](#l6.30)
self._file = open(self._filename, self._mode)[](#l6.31) self._buffer = self._file.readlines(self._bufsize)[](#l6.32) self._bufindex = 0[](#l6.33) if not self._buffer:[](#l6.34)
@@ -396,12 +396,12 @@ def hook_compressed(filename, mode): import bz2 return bz2.BZ2File(filename, mode) else:
return open(filename, mode, cloexec=True)[](#l6.39)
return open(filename, mode)[](#l6.40)
def hook_encoded(encoding): def openhook(filename, mode):
return open(filename, mode, encoding=encoding, cloexec=True)[](#l6.45)
--- a/Lib/gettext.py +++ b/Lib/gettext.py @@ -406,7 +406,7 @@ def translation(domain, localedir=None, key = (class_, os.path.abspath(mofile)) t = _translations.get(key) if t is None:
with open(mofile, 'rb', cloexec=True) as fp:[](#l7.7)
with open(mofile, 'rb') as fp:[](#l7.8) t = _translations.setdefault(key, class_(fp))[](#l7.9) # Copy the translation object to allow setting fallbacks and[](#l7.10) # output charset. All other instance data is shared with the[](#l7.11)
--- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -181,7 +181,7 @@ class GzipFile(io.BufferedIOBase): if mode and 'b' not in mode: mode += 'b' if fileobj is None:
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb', cloexec=True)[](#l8.7)
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')[](#l8.8) if filename is None:[](#l8.9) filename = getattr(fileobj, 'name', '')[](#l8.10) if not isinstance(filename, (str, bytes)):[](#l8.11)
--- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1761,7 +1761,7 @@ class FileCookieJar(CookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)
f = open(filename, cloexec=True)[](#l9.7)
f = open(filename)[](#l9.8) try:[](#l9.9) self._really_load(f, filename, ignore_discard, ignore_expires)[](#l9.10) finally:[](#l9.11)
@@ -1856,7 +1856,7 @@ class LWPCookieJar(FileCookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)
f = open(filename, "w", cloexec=True)[](#l9.16)
f = open(filename, "w")[](#l9.17) try:[](#l9.18) # There really isn't an LWP Cookies 2.0 format, but this indicates[](#l9.19) # that there is extra information in here (domain_dot and[](#l9.20)
@@ -2055,7 +2055,7 @@ class MozillaCookieJar(FileCookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)
f = open(filename, "w", cloexec=True)[](#l9.25)
f = open(filename, "w")[](#l9.26) try:[](#l9.27) f.write(self.header)[](#l9.28) now = time.time()[](#l9.29)
--- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -9,7 +9,7 @@ def what(file, h=None): if h is None: if isinstance(file, str):
f = open(file, 'rb', cloexec=True)[](#l10.7)
f = open(file, 'rb')[](#l10.8) h = f.read(32)[](#l10.9) else:[](#l10.10) location = file.tell()[](#l10.11)
--- a/Lib/imp.py +++ b/Lib/imp.py @@ -221,9 +221,9 @@ def find_module(name, path=None): encoding = None if mode == 'U':
with open(file_path, 'rb', cloexec=True) as file:[](#l11.7)
with open(file_path, 'rb') as file:[](#l11.8) encoding = tokenize.detect_encoding(file.readline)[0][](#l11.9)
--- a/Lib/lzma.py +++ b/Lib/lzma.py @@ -124,7 +124,7 @@ class LZMAFile(io.BufferedIOBase): if isinstance(filename, (str, bytes)): if "b" not in mode: mode += "b"
self._fp = builtins.open(filename, mode, cloexec=True)[](#l12.7)
self._fp = builtins.open(filename, mode)[](#l12.8) self._closefp = True[](#l12.9) self._mode = mode_code[](#l12.10) elif hasattr(filename, "read") or hasattr(filename, "write"):[](#l12.11)
--- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -366,7 +366,7 @@ class Maildir(Mailbox): def get_message(self, key): """Return a Message representation or raise a KeyError.""" subpath = self._lookup(key)
f = open(os.path.join(self._path, subpath), 'rb', cloexec=True)[](#l13.7)
f = open(os.path.join(self._path, subpath), 'rb')[](#l13.8) try:[](#l13.9) if self._factory:[](#l13.10) msg = self._factory(f)[](#l13.11)
@@ -383,7 +383,7 @@ class Maildir(Mailbox): def get_bytes(self, key): """Return a bytes representation or raise a KeyError."""
f = open(os.path.join(self._path, self._lookup(key)), 'rb', cloexec=True)[](#l13.16)
f = open(os.path.join(self._path, self._lookup(key)), 'rb')[](#l13.17) try:[](#l13.18) return f.read().replace(linesep, b'\n')[](#l13.19) finally:[](#l13.20)
@@ -391,7 +391,7 @@ class Maildir(Mailbox): def get_file(self, key): """Return a file-like representation or raise a KeyError."""
f = open(os.path.join(self._path, self._lookup(key)), 'rb', cloexec=True)[](#l13.25)
f = open(os.path.join(self._path, self._lookup(key)), 'rb')[](#l13.26) return _ProxyFile(f)[](#l13.27)
def iterkeys(self): @@ -454,7 +454,7 @@ class Maildir(Mailbox): maildirfolder_path = os.path.join(path, 'maildirfolder') if not os.path.exists(maildirfolder_path): os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY,
0o666, cloexec=True))[](#l13.34)
0o666))[](#l13.35) return result[](#l13.36)
def remove_folder(self, folder): @@ -584,15 +584,15 @@ class _singlefileMailbox(Mailbox): """Initialize a single-file mailbox.""" Mailbox.init(self, path, factory, create) try:
f = open(self._path, 'rb+', cloexec=True)[](#l13.43)
f = open(self._path, 'rb+')[](#l13.44) except OSError as e:[](#l13.45) if e.errno == errno.ENOENT:[](#l13.46) if create:[](#l13.47)
f = open(self._path, 'wb+', cloexec=True)[](#l13.48)
f = open(self._path, 'wb+')[](#l13.49) else:[](#l13.50) raise NoSuchMailboxError(self._path)[](#l13.51) elif e.errno in (errno.EACCES, errno.EROFS):[](#l13.52)
f = open(self._path, 'rb', cloexec=True)[](#l13.53)
f = open(self._path, 'rb')[](#l13.54) else:[](#l13.55) raise[](#l13.56) self._file = f[](#l13.57)
@@ -712,7 +712,7 @@ class _singlefileMailbox(Mailbox): os.rename(new_file.name, self._path) else: raise
self._file = open(self._path, 'rb+', cloexec=True)[](#l13.62)
self._file = open(self._path, 'rb+')[](#l13.63) self._toc = new_toc[](#l13.64) self._pending = False[](#l13.65) self._pending_sync = False[](#l13.66)
@@ -944,8 +944,7 @@ class MH(Mailbox): if create: os.mkdir(self._path, 0o700) os.close(os.open(os.path.join(self._path, '.mh_sequences'),
os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600,[](#l13.71)
cloexec=True))[](#l13.72)
os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600))[](#l13.73) else:[](#l13.74) raise NoSuchMailboxError(self._path)[](#l13.75) self._locked = False[](#l13.76)
@@ -988,7 +987,7 @@ class MH(Mailbox): """Remove the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try:
f = open(path, 'rb+', cloexec=True)[](#l13.81)
f = open(path, 'rb+')[](#l13.82) except OSError as e:[](#l13.83) if e.errno == errno.ENOENT:[](#l13.84) raise KeyError('No message with key: %s' % key)[](#l13.85)
@@ -1002,7 +1001,7 @@ class MH(Mailbox): """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try:
f = open(path, 'rb+', cloexec=True)[](#l13.90)
f = open(path, 'rb+')[](#l13.91) except OSError as e:[](#l13.92) if e.errno == errno.ENOENT:[](#l13.93) raise KeyError('No message with key: %s' % key)[](#l13.94)
@@ -1012,7 +1011,7 @@ class MH(Mailbox): if self._locked: _lock_file(f) try:
os.close(os.open(path, os.O_WRONLY | os.O_TRUNC, cloexec=True))[](#l13.99)
os.close(os.open(path, os.O_WRONLY | os.O_TRUNC))[](#l13.100) self._dump_message(message, f)[](#l13.101) if isinstance(message, MHMessage):[](#l13.102) self._dump_sequences(message, key)[](#l13.103)
@@ -1026,9 +1025,9 @@ class MH(Mailbox): """Return a Message representation or raise a KeyError.""" try: if self._locked:
f = open(os.path.join(self._path, str(key)), 'rb+', cloexec=True)[](#l13.108)
f = open(os.path.join(self._path, str(key)), 'rb+')[](#l13.109) else:[](#l13.110)
f = open(os.path.join(self._path, str(key)), 'rb', cloexec=True)[](#l13.111)
f = open(os.path.join(self._path, str(key)), 'rb')[](#l13.112) except OSError as e:[](#l13.113) if e.errno == errno.ENOENT:[](#l13.114) raise KeyError('No message with key: %s' % key)[](#l13.115)
@@ -1053,9 +1052,9 @@ class MH(Mailbox): """Return a bytes representation or raise a KeyError.""" try: if self._locked:
f = open(os.path.join(self._path, str(key)), 'rb+', cloexec=True)[](#l13.120)
f = open(os.path.join(self._path, str(key)), 'rb+')[](#l13.121) else:[](#l13.122)
f = open(os.path.join(self._path, str(key)), 'rb', cloexec=True)[](#l13.123)
f = open(os.path.join(self._path, str(key)), 'rb')[](#l13.124) except OSError as e:[](#l13.125) if e.errno == errno.ENOENT:[](#l13.126) raise KeyError('No message with key: %s' % key)[](#l13.127)
@@ -1075,7 +1074,7 @@ class MH(Mailbox): def get_file(self, key): """Return a file-like representation or raise a KeyError.""" try:
f = open(os.path.join(self._path, str(key)), 'rb', cloexec=True)[](#l13.132)
f = open(os.path.join(self._path, str(key)), 'rb')[](#l13.133) except OSError as e:[](#l13.134) if e.errno == errno.ENOENT:[](#l13.135) raise KeyError('No message with key: %s' % key)[](#l13.136)
@@ -1099,7 +1098,7 @@ class MH(Mailbox): def lock(self): """Lock the mailbox.""" if not self._locked:
self._file = open(os.path.join(self._path, '.mh_sequences'), 'rb+', cloexec=True)[](#l13.141)
self._file = open(os.path.join(self._path, '.mh_sequences'), 'rb+')[](#l13.142) _lock_file(self._file)[](#l13.143) self._locked = True[](#l13.144)
@@ -1153,7 +1152,7 @@ class MH(Mailbox): def get_sequences(self): """Return a name-to-key-list dictionary to define each sequence.""" results = {}
with open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII', cloexec=True) as f:[](#l13.150)
with open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII') as f:[](#l13.151) all_keys = set(self.keys())[](#l13.152) for line in f:[](#l13.153) try:[](#l13.154)
@@ -1176,9 +1175,9 @@ class MH(Mailbox): def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary."""
f = open(os.path.join(self._path, '.mh_sequences'), 'r+', encoding='ASCII', cloexec=True)[](#l13.159)
f = open(os.path.join(self._path, '.mh_sequences'), 'r+', encoding='ASCII')[](#l13.160) try:[](#l13.161)
os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC, cloexec=True))[](#l13.162)
os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))[](#l13.163) for name, keys in sequences.items():[](#l13.164) if len(keys) == 0:[](#l13.165) continue[](#l13.166)
@@ -2115,9 +2114,9 @@ def _unlock_file(f): def _create_carefully(path): """Create a file if it doesn't exist and open for reading and writing."""
return open(path, 'rb+', cloexec=True)[](#l13.174)
--- a/Lib/mailcap.py +++ b/Lib/mailcap.py @@ -19,7 +19,7 @@ def getcaps(): caps = {} for mailcap in listmailcapfiles(): try:
fp = open(mailcap, 'r', cloexec=True)[](#l14.7)
fp = open(mailcap, 'r')[](#l14.8) except OSError:[](#l14.9) continue[](#l14.10) morecaps = readmailcapfile(fp)[](#l14.11)
--- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -199,7 +199,7 @@ class MimeTypes: list of standard types, else to the list of non-standard types. """
with open(filename, encoding='utf-8', cloexec=True) as fp:[](#l15.7)
with open(filename, encoding='utf-8') as fp:[](#l15.8) self.readfp(fp, strict)[](#l15.9)
def readfp(self, fp, strict=True): @@ -358,7 +358,7 @@ def init(files=None): def read_mime_types(file): try:
f = open(file, cloexec=True)[](#l15.16)
--- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -102,14 +102,14 @@ class ModuleFinder: def run_script(self, pathname): self.msg(2, "run_script", pathname)
with open(pathname, cloexec=True) as fp:[](#l16.7)
with open(pathname) as fp:[](#l16.8) stuff = ("", "r", imp.PY_SOURCE)[](#l16.9) self.load_module('__main__', fp, pathname, stuff)[](#l16.10)
def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name)
with open(pathname, cloexec=True) as fp:[](#l16.15)
with open(pathname) as fp:[](#l16.16) stuff = (ext, "r", imp.PY_SOURCE)[](#l16.17) self.load_module(name, fp, pathname, stuff)[](#l16.18)
--- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -28,7 +28,7 @@ class netrc: raise OSError("Could not find .netrc: $HOME is not set") self.hosts = {} self.macros = {}
with open(file, cloexec=True) as fp:[](#l17.7)
with open(file) as fp:[](#l17.8) self._parse(file, fp)[](#l17.9)
--- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -464,7 +464,7 @@ class _NNTPBase: try: # If a string was passed then open a file with that name if isinstance(file, (str, bytes)):
openedFile = file = open(file, "wb", cloexec=True)[](#l18.7)
openedFile = file = open(file, "wb")[](#l18.8)
resp = self._getresp() if resp[:3] not in _LONGRESP:
--- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -880,9 +880,7 @@ class Values: def read_file(self, filename, mode="careful"): vars = {}
with open(filename, cloexec=True) as fp:[](#l19.7)
content = fp.read()[](#l19.8)
exec(content, vars)[](#l19.9)
exec(open(filename).read(), vars)[](#l19.10) self._update(vars, mode)[](#l19.11)
def ensure_value(self, attr, value):
--- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -91,7 +91,7 @@ class Restart(Exception): def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try:
fp = open(filename, cloexec=True)[](#l20.7)
except OSError: return Nonefp = open(filename)[](#l20.8)
@@ -168,12 +168,12 @@ class Pdb(bdb.Bdb, cmd.Cmd): consumer of this info expects the first line to be 1 if 'HOME' in os.environ: envHome = os.environ['HOME'] try:
with open(os.path.join(envHome, ".pdbrc"), cloexec=True) as rcFile:[](#l20.16)
with open(os.path.join(envHome, ".pdbrc")) as rcFile:[](#l20.17) self.rcLines.extend(rcFile)[](#l20.18) except OSError:[](#l20.19) pass[](#l20.20) try:[](#l20.21)
with open(".pdbrc", cloexec=True) as rcFile:[](#l20.22)
with open(".pdbrc") as rcFile:[](#l20.23) self.rcLines.extend(rcFile)[](#l20.24) except OSError:[](#l20.25) pass[](#l20.26)
@@ -1533,7 +1533,7 @@ class Pdb(bdb.Bdb, cmd.Cmd): self._wait_for_mainpyfile = True self.mainpyfile = self.canonic(filename) self._user_requested_quit = False
with open(filename, "rb", cloexec=True) as fp:[](#l20.31)
with open(filename, "rb") as fp:[](#l20.32) statement = "exec(compile(%r, %r, 'exec'))" % \[](#l20.33) (fp.read(), self.mainpyfile)[](#l20.34) self.run(statement)[](#l20.35)
--- a/Lib/pipes.py +++ b/Lib/pipes.py @@ -153,7 +153,7 @@ class Template: """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" if not self.steps:
return open(file, 'r', cloexec=True)[](#l21.7)
return open(file, 'r')[](#l21.8) if self.steps[-1][1] == SINK:[](#l21.9) raise ValueError('Template.open_r: pipeline ends width SINK')[](#l21.10) cmd = self.makepipeline(file, '')[](#l21.11)
@@ -161,7 +161,7 @@ class Template: def open_w(self, file): if not self.steps:
return open(file, 'w', cloexec=True)[](#l21.16)
return open(file, 'w')[](#l21.17) if self.steps[0][1] == SOURCE:[](#l21.18) raise ValueError('Template.open_w: pipeline begins with SOURCE')[](#l21.19) cmd = self.makepipeline('', file)[](#l21.20)
--- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -297,16 +297,16 @@ class ImpLoader: return mod def get_data(self, pathname):
with open(pathname, "rb", cloexec=True) as file:[](#l22.7)
with open(pathname, "rb") as file:[](#l22.8) return file.read()[](#l22.9)
def _reopen(self): if self.file and self.file.closed: mod_type = self.etc[2] if mod_type==imp.PY_SOURCE:
self.file = open(self.filename, 'r', cloexec=True)[](#l22.15)
self.file = open(self.filename, 'r')[](#l22.16) elif mod_type in (imp.PY_COMPILED, imp.C_EXTENSION):[](#l22.17)
self.file = open(self.filename, 'rb', cloexec=True)[](#l22.18)
self.file = open(self.filename, 'rb')[](#l22.19)
def _fix_name(self, fullname): if fullname is None: @@ -349,7 +349,7 @@ class ImpLoader: self.file.close() elif mod_type==imp.PY_COMPILED: if os.path.exists(self.filename[:-1]):
f = open(self.filename[:-1], 'r', cloexec=True)[](#l22.27)
f = open(self.filename[:-1], 'r')[](#l22.28) self.source = f.read()[](#l22.29) f.close()[](#l22.30) elif mod_type==imp.PKG_DIRECTORY:[](#l22.31)
@@ -586,7 +586,7 @@ def extend_path(path, name): pkgfile = os.path.join(dir, sname_pkg) if os.path.isfile(pkgfile): try:
f = open(pkgfile, cloexec=True)[](#l22.36)
f = open(pkgfile)[](#l22.37) except OSError as msg:[](#l22.38) sys.stderr.write("Can't open %s: %s\n" %[](#l22.39) (pkgfile, msg))[](#l22.40)
--- a/Lib/platform.py +++ b/Lib/platform.py @@ -159,7 +159,7 @@ def libc_ver(executable=sys.executable,l # here to work around problems with Cygwin not being # able to open symlinks for reading executable = os.path.realpath(executable)
- f = open(executable,'rb') binary = f.read(chunksize) pos = 0 while 1: @@ -207,7 +207,7 @@ def _dist_try_harder(distname,version,id if os.path.exists('/var/adm/inst-log/info'): # SuSE Linux stores distribution information in that file distname = 'SuSE'
for line in open('/var/adm/inst-log/info', cloexec=True):[](#l23.16)
for line in open('/var/adm/inst-log/info'):[](#l23.17) tv = line.split()[](#l23.18) if len(tv) == 2:[](#l23.19) tag,value = tv[](#l23.20)
@@ -222,7 +222,7 @@ def _dist_try_harder(distname,version,id if os.path.exists('/etc/.installed'): # Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
for line in open('/etc/.installed', cloexec=True):[](#l23.25)
for line in open('/etc/.installed'):[](#l23.26) pkg = line.split('-')[](#l23.27) if len(pkg) >= 2 and pkg[0] == 'OpenLinux':[](#l23.28) # XXX does Caldera support non Intel platforms ? If yes,[](#l23.29)
@@ -331,7 +331,7 @@ def linux_distribution(distname='', vers return _dist_try_harder(distname,version,id) # Read the first line
- with open('/etc/'+file, 'r') as f: firstline = f.readline() _distname, _version, _id = _parse_release_file(firstline)
--- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -70,7 +70,7 @@ def readPlist(pathOrFile): didOpen = False try: if isinstance(pathOrFile, str):
pathOrFile = open(pathOrFile, 'rb', cloexec=True)[](#l24.7)
pathOrFile = open(pathOrFile, 'rb')[](#l24.8) didOpen = True[](#l24.9) p = PlistParser()[](#l24.10) rootObject = p.parse(pathOrFile)[](#l24.11)
@@ -87,7 +87,7 @@ def writePlist(rootObject, pathOrFile): didOpen = False try: if isinstance(pathOrFile, str):
pathOrFile = open(pathOrFile, 'wb', cloexec=True)[](#l24.16)
pathOrFile = open(pathOrFile, 'wb')[](#l24.17) didOpen = True[](#l24.18) writer = PlistWriter(pathOrFile)[](#l24.19) writer.writeln("<plist version=\"1.0\">")[](#l24.20)
--- a/Lib/profile.py +++ b/Lib/profile.py @@ -373,7 +373,7 @@ class Profile: print_stats() def dump_stats(self, file):
f = open(file, 'wb', cloexec=True)[](#l25.7)
f = open(file, 'wb')[](#l25.8) self.create_stats()[](#l25.9) marshal.dump(self.stats, f)[](#l25.10) f.close()[](#l25.11)
@@ -554,7 +554,7 @@ def main(): if len(args) > 0: progname = args[0] sys.path.insert(0, os.path.dirname(progname))
with open(progname, 'rb', cloexec=True) as fp:[](#l25.16)
with open(progname, 'rb') as fp:[](#l25.17) code = compile(fp.read(), progname, 'exec')[](#l25.18) globs = {[](#l25.19) '__file__': progname,[](#l25.20)
--- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -93,7 +93,7 @@ class Stats: self.stats = {} return elif isinstance(arg, str):
f = open(arg, 'rb', cloexec=True)[](#l26.7)
f = open(arg, 'rb')[](#l26.8) self.stats = marshal.load(f)[](#l26.9) f.close()[](#l26.10) try:[](#l26.11)
@@ -149,7 +149,7 @@ class Stats: def dump_stats(self, filename): """Write the profile data to a file we know how to load back."""
f = open(filename, 'wb', cloexec=True)[](#l26.16)
f = open(filename, 'wb')[](#l26.17) try:[](#l26.18) marshal.dump(self.stats, f)[](#l26.19) finally:[](#l26.20)
--- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -138,7 +138,7 @@ def compile(file, cfile=None, dfile=None except OSError as error: if error.errno != errno.EEXIST: raise
--- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -198,11 +198,11 @@ def _get_main_module_details(): def _get_code_from_file(run_name, fname): # Check for a compiled file first
- with open(fname, "rb") as f: code = read_code(f) if code is None: # That didn't work, so try it as normal source code
with open(fname, "rb", cloexec=True) as f:[](#l28.12)
else:with open(fname, "rb") as f:[](#l28.13) code = compile(f.read(), fname, 'exec')[](#l28.14) loader = importlib.machinery.SourceFileLoader(run_name, fname)[](#l28.15)
--- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -249,7 +249,7 @@ class shlex: # This implements cpp-like semantics for relative-path inclusion. if isinstance(self.infile, str) and not os.path.isabs(newfile): newfile = os.path.join(os.path.dirname(self.infile), newfile)
return (newfile, open(newfile, "r", cloexec=True))[](#l29.7)
return (newfile, open(newfile, "r"))[](#l29.8)
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." @@ -295,7 +295,7 @@ if name == 'main': lexer = shlex() else: file = sys.argv[1]
lexer = shlex(open(file, cloexec=True), file)[](#l29.16)
--- a/Lib/site.py +++ b/Lib/site.py @@ -152,7 +152,7 @@ def addpackage(sitedir, name, known_path reset = 0 fullname = os.path.join(sitedir, name) try:
f = open(fullname, "r", cloexec=True)[](#l30.7)
except OSError: return with f: @@ -384,7 +384,7 @@ class _Printer(object): for filename in self.__files: filename = os.path.join(dir, filename) try:f = open(fullname, "r")[](#l30.8)
fp = open(filename, "r", cloexec=True)[](#l30.16)
fp = open(filename, "r")[](#l30.17) data = fp.read()[](#l30.18) fp.close()[](#l30.19) break[](#l30.20)
@@ -499,7 +499,7 @@ def venv(known_paths): if candidate_confs: virtual_conf = candidate_confs[0] system_site = "true"
with open(virtual_conf, cloexec=True) as f:[](#l30.25)
with open(virtual_conf) as f:[](#l30.26) for line in f:[](#l30.27) line = line.strip()[](#l30.28) m = CONFIG_LINE.match(line)[](#l30.29)
--- a/Lib/sndhdr.py +++ b/Lib/sndhdr.py @@ -40,7 +40,7 @@ def what(filename): def whathdr(filename): """Recognize sound headers."""
--- a/Lib/sunau.py +++ b/Lib/sunau.py @@ -153,7 +153,7 @@ class Au_read: def init(self, f): if type(f) == type(''): import builtins
f = builtins.open(f, 'rb', cloexec=True)[](#l32.7)
f = builtins.open(f, 'rb')[](#l32.8) self._opened = True[](#l32.9) else:[](#l32.10) self._opened = False[](#l32.11)
@@ -287,7 +287,7 @@ class Au_write: def init(self, f): if type(f) == type(''): import builtins
f = builtins.open(f, 'wb', cloexec=True)[](#l32.16)
f = builtins.open(f, 'wb')[](#l32.17) self._opened = True[](#l32.18) else:[](#l32.19) self._opened = False[](#l32.20)
--- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -231,7 +231,7 @@ def _parse_makefile(filename, vars=None) done = {} notdone = {}
for line in lines: @@ -357,7 +357,7 @@ def _generate_posix_vars(): # load the installed pyconfig.h: config_h = get_config_h_filename() try:
with open(config_h, cloexec=True) as f:[](#l33.16)
except OSError as e: msg = "invalid Python installation: unable to open %s" % config_hwith open(config_h) as f:[](#l33.17) parse_config_h(f, vars)[](#l33.18)
@@ -394,14 +394,14 @@ def _generate_posix_vars(): os.makedirs(pybuilddir, exist_ok=True) destfile = os.path.join(pybuilddir, name + '.py')
- with open(destfile, 'w', encoding='utf8') as f: f.write('# system configuration generated and used by' ' the sysconfig module\n') f.write('build_time_vars = ') pprint.pprint(vars, stream=f)
# Create file used for sys.path fixup -- see Modules/getpath.c
--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -332,7 +332,7 @@ class _LowLevelFile: }[mode] if hasattr(os, "O_BINARY"): mode |= os.O_BINARY
self.fd = os.open(name, mode, 0o666, cloexec=True)[](#l34.7)
self.fd = os.open(name, mode, 0o666)[](#l34.8)
def close(self): os.close(self.fd) @@ -1439,7 +1439,7 @@ class TarFile(object): # Create nonexistent files in append mode. self.mode = "w" self._mode = "wb"
fileobj = bltn_open(name, self._mode, cloexec=True)[](#l34.16)
fileobj = bltn_open(name, self._mode)[](#l34.17) self._extfileobj = False[](#l34.18) else:[](#l34.19) if name is None and hasattr(fileobj, "name"):[](#l34.20)
--- a/Lib/tkinter/init.py +++ b/Lib/tkinter/init.py @@ -1849,15 +1849,11 @@ class Tk(Misc, Wm): if os.path.isfile(class_tcl): self.tk.call('source', class_tcl) if os.path.isfile(class_py):
with open(class_py, cloexec=True) as fp:[](#l35.7)
content = fp.read()[](#l35.8)
exec(content, dir)[](#l35.9)
exec(open(class_py).read(), dir)[](#l35.10) if os.path.isfile(base_tcl):[](#l35.11) self.tk.call('source', base_tcl)[](#l35.12) if os.path.isfile(base_py):[](#l35.13)
with open(base_py, cloexec=True) as fp:[](#l35.14)
content = fp.read()[](#l35.15)
exec(content, dir)[](#l35.16)
def report_callback_exception(self, exc, val, tb): """Internal function. It reports exception on sys.stderr.""" import tracebackexec(open(base_py).read(), dir)[](#l35.17)
--- a/Lib/tkinter/filedialog.py +++ b/Lib/tkinter/filedialog.py @@ -395,7 +395,7 @@ def askopenfile(mode = "r", **options): filename = Open(**options).show() if filename:
return open(filename, mode, cloexec=True)[](#l36.7)
return None def askopenfiles(mode = "r", **options): @@ -410,7 +410,7 @@ def askopenfiles(mode = "r", **options): if files: ofiles=[] for filename in files:return open(filename, mode)[](#l36.8)
ofiles.append(open(filename, mode, cloexec=True))[](#l36.16)
return files @@ -420,7 +420,7 @@ def asksaveasfile(mode = "w", **options) filename = SaveAs(**options).show() if filename:ofiles.append(open(filename, mode))[](#l36.17) files=ofiles[](#l36.18)
return open(filename, mode, cloexec=True)[](#l36.25)
return None def askdirectory (*options): @@ -462,7 +462,7 @@ def test(): openfilename=askopenfilename(filetypes=[("all files", "")]) try:return open(filename, mode)[](#l36.26)
fp=open(openfilename, "r", cloexec=True)[](#l36.34)
--- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -425,7 +425,7 @@ def open(filename): """Open a file in read only mode using the encoding detected by detect_encoding(). """
- buffer = builtins.open(filename, 'rb') encoding, lines = detect_encoding(buffer.readline) buffer.seek(0) text = TextIOWrapper(buffer, encoding, line_buffering=True) @@ -648,7 +648,7 @@ def main(): # Tokenize the input if args.filename: filename = args.filename
with builtins.open(filename, 'rb', cloexec=True) as f:[](#l37.16)
with builtins.open(filename, 'rb') as f:[](#l37.17) tokens = list(tokenize(f.readline))[](#l37.18) else:[](#l37.19) filename = "<stdin>"[](#l37.20)
--- a/Lib/trace.py +++ b/Lib/trace.py @@ -235,7 +235,7 @@ class CoverageResults: # Try to merge existing counts file. try: counts, calledfuncs, callers = [](#l38.6)
pickle.load(open(self.infile, 'rb', cloexec=True))[](#l38.7)
pickle.load(open(self.infile, 'rb'))[](#l38.8) self.update(self.__class__(counts, calledfuncs, callers))[](#l38.9) except (OSError, EOFError, ValueError) as err:[](#l38.10) print(("Skipping counts file %r: %s"[](#l38.11)
@@ -328,7 +328,7 @@ class CoverageResults: source = linecache.getlines(filename) coverpath = os.path.join(dir, modulename + ".cover")
with open(filename, 'rb', cloexec=True) as fp:[](#l38.16)
with open(filename, 'rb') as fp:[](#l38.17) encoding, _ = tokenize.detect_encoding(fp.readline)[](#l38.18) n_hits, n_lines = self.write_results_file(coverpath, source,[](#l38.19) lnotab, count, encoding)[](#l38.20)
@@ -346,7 +346,7 @@ class CoverageResults: # try and store counts and module info into self.outfile try: pickle.dump((self.counts, self.calledfuncs, self.callers),
open(self.outfile, 'wb', cloexec=True), 1)[](#l38.25)
open(self.outfile, 'wb'), 1)[](#l38.26) except OSError as err:[](#l38.27) print("Can't save counts files because %s" % err, file=sys.stderr)[](#l38.28)
@@ -354,7 +354,7 @@ class CoverageResults: """Return a coverage results file in path.""" try:
outfile = open(path, "w", encoding=encoding, cloexec=True)[](#l38.34)
outfile = open(path, "w", encoding=encoding)[](#l38.35) except OSError as err:[](#l38.36) print(("trace: Could not open %r for writing: %s"[](#l38.37) "- skipping" % (path, err)), file=sys.stderr)[](#l38.38)
@@ -418,7 +418,7 @@ def _find_strings(filename, encoding=Non # If the first token is a string, then it's the module docstring. # Add this special case so that the test in the loop passes. prev_ttype = token.INDENT
- with open(filename, encoding=encoding) as f: tok = tokenize.generate_tokens(f.readline) for ttype, tstr, start, end, line in tok: if ttype == token.STRING:
@@ -791,7 +791,7 @@ def main(argv=None): ignoredirs=ignore_dirs, infile=counts_file, outfile=counts_file, timing=timing) try:
with open(progname, cloexec=True) as fp:[](#l38.52)
with open(progname) as fp:[](#l38.53) code = compile(fp.read(), progname, 'exec')[](#l38.54) # try to emulate __main__ namespace as much as possible[](#l38.55) globs = {[](#l38.56)
--- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -169,7 +169,7 @@ from tkinter import simpledialog def config_dict(filename): """Convert content of config-file into dictionary."""
- with open(filename, "r") as f: cfglines = f.readlines() cfgdict = {} for line in cfglines: @@ -3843,7 +3843,7 @@ def write_docstringdict(filename="turtle key = "Turtle."+methodname docsdict[key] = eval(key).doc
- f = open("%s.py" % filename,"w") keys = sorted([x for x in docsdict.keys() if x.split('.')[1] not in _alias_list]) f.write('docsdict = {\n\n')
--- a/Lib/turtledemo/main.py +++ b/Lib/turtledemo/main.py @@ -188,7 +188,7 @@ class DemoWindow(object): modname = 'turtledemo.' + filename import(modname) self.module = sys.modules[modname]
with open(self.module.__file__, 'r', cloexec=True) as f:[](#l40.7)
with open(self.module.__file__, 'r') as f:[](#l40.8) chars = f.read()[](#l40.9) self.text.delete("1.0", "end")[](#l40.10) self.text.insert("1.0", chars)[](#l40.11)
--- a/Lib/uu.py +++ b/Lib/uu.py @@ -56,7 +56,7 @@ def encode(in_file, out_file, name=None, mode = os.stat(in_file).st_mode except AttributeError: pass
in_file = open(in_file, 'rb', cloexec=True)[](#l41.7)
in_file = open(in_file, 'rb')[](#l41.8) opened_files.append(in_file)[](#l41.9) #[](#l41.10) # Open out_file if it is a pathname[](#l41.11)
@@ -64,7 +64,7 @@ def encode(in_file, out_file, name=None, if out_file == '-': out_file = sys.stdout.buffer elif isinstance(out_file, str):
out_file = open(out_file, 'wb', cloexec=True)[](#l41.16)
out_file = open(out_file, 'wb')[](#l41.17) opened_files.append(out_file)[](#l41.18) #[](#l41.19) # Set defaults for name and mode[](#l41.20)
@@ -96,7 +96,7 @@ def decode(in_file, out_file=None, mode= if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str):
in_file = open(in_file, 'rb', cloexec=True)[](#l41.25)
in_file = open(in_file, 'rb')[](#l41.26) opened_files.append(in_file)[](#l41.27)
try: @@ -129,7 +129,7 @@ def decode(in_file, out_file=None, mode= if out_file == '-': out_file = sys.stdout.buffer elif isinstance(out_file, str):
fp = open(out_file, 'wb', cloexec=True)[](#l41.34)
fp = open(out_file, 'wb')[](#l41.35) try:[](#l41.36) os.path.chmod(out_file, mode)[](#l41.37) except AttributeError:[](#l41.38)
@@ -181,7 +181,7 @@ def test(): if options.decode: if options.text: if isinstance(output, str):
output = open(output, 'wb', cloexec=True)[](#l41.43)
output = open(output, 'wb')[](#l41.44) else:[](#l41.45) print(sys.argv[0], ': cannot do -t to stdout')[](#l41.46) sys.exit(1)[](#l41.47)
@@ -189,7 +189,7 @@ def test(): else: if options.text: if isinstance(input, str):
input = open(input, 'rb', cloexec=True)[](#l41.52)
input = open(input, 'rb')[](#l41.53) else:[](#l41.54) print(sys.argv[0], ': cannot do -t from stdin')[](#l41.55) sys.exit(1)[](#l41.56)
--- a/Lib/wave.py +++ b/Lib/wave.py @@ -156,7 +156,7 @@ class Wave_read: def init(self, f): self._i_opened_the_file = None if isinstance(f, str):
f = builtins.open(f, 'rb', cloexec=True)[](#l42.7)
f = builtins.open(f, 'rb')[](#l42.8) self._i_opened_the_file = f[](#l42.9) # else, assume it is an open file object already[](#l42.10) try:[](#l42.11)
@@ -300,7 +300,7 @@ class Wave_write: def init(self, f): self._i_opened_the_file = None if isinstance(f, str):
f = builtins.open(f, 'wb', cloexec=True)[](#l42.16)
f = builtins.open(f, 'wb')[](#l42.17) self._i_opened_the_file = f[](#l42.18) try:[](#l42.19) self.initfp(f)[](#l42.20)
--- a/Lib/xml/dom/expatbuilder.py +++ b/Lib/xml/dom/expatbuilder.py @@ -905,7 +905,7 @@ def parse(file, namespaces=True): builder = ExpatBuilder() if isinstance(file, str):
fp = open(file, 'rb', cloexec=True)[](#l43.7)
fp = open(file, 'rb')[](#l43.8) try:[](#l43.9) result = builder.parseFile(fp)[](#l43.10) finally:[](#l43.11)
@@ -939,7 +939,7 @@ def parseFragment(file, context, namespa builder = FragmentBuilder(context) if isinstance(file, str):
fp = open(file, 'rb', cloexec=True)[](#l43.16)
fp = open(file, 'rb')[](#l43.17) try:[](#l43.18) result = builder.parseFile(fp)[](#l43.19) finally:[](#l43.20)
--- a/Lib/xml/dom/pulldom.py +++ b/Lib/xml/dom/pulldom.py @@ -325,7 +325,7 @@ def parse(stream_or_string, parser=None, if bufsize is None: bufsize = default_bufsize if isinstance(stream_or_string, str):
stream = open(stream_or_string, 'rb', cloexec=True)[](#l44.7)
--- a/Lib/xml/etree/ElementInclude.py +++ b/Lib/xml/etree/ElementInclude.py @@ -76,12 +76,12 @@ class FatalIncludeError(SyntaxError): def default_loader(href, parse, encoding=None): if parse == "xml":
file = open(href, 'rb', cloexec=True)[](#l45.7)
else: if not encoding: encoding = 'UTF-8'file = open(href, 'rb')[](#l45.8) data = ElementTree.parse(file).getroot()[](#l45.9)
file = open(href, 'r', encoding=encoding, cloexec=True)[](#l45.13)
file.close() return datafile = open(href, 'r', encoding=encoding)[](#l45.14) data = file.read()[](#l45.15)
--- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -651,7 +651,7 @@ class ElementTree: def parse(self, source, parser=None): close_source = False if not hasattr(source, "read"):
source = open(source, "rb", cloexec=True)[](#l46.7)
source = open(source, "rb")[](#l46.8) close_source = True[](#l46.9) try:[](#l46.10) if not parser:[](#l46.11)
@@ -844,10 +844,10 @@ def _get_writer(file_or_filename, encodi except AttributeError: # file_or_filename is a file name if encoding == "unicode":
file = open(file_or_filename, "w", cloexec=True)[](#l46.16)
file = open(file_or_filename, "w")[](#l46.17) else:[](#l46.18) file = open(file_or_filename, "w", encoding=encoding,[](#l46.19)
errors="xmlcharrefreplace", cloexec=True)[](#l46.20)
else: @@ -1265,7 +1265,7 @@ def parse(source, parser=None): def iterparse(source, events=None, parser=None): close_source = False if not hasattr(source, "read"):errors="xmlcharrefreplace")[](#l46.21) with file:[](#l46.22) yield file.write[](#l46.23)
source = open(source, "rb", cloexec=True)[](#l46.29)
if not parser: parser = XMLParser(target=TreeBuilder())source = open(source, "rb")[](#l46.30) close_source = True[](#l46.31)
@@ -1724,7 +1724,7 @@ else: def parse(self, source, parser=None): close_source = False if not hasattr(source, 'read'):
source = open(source, 'rb', cloexec=True)[](#l46.38)
source = open(source, 'rb')[](#l46.39) close_source = True[](#l46.40) try:[](#l46.41) if parser is not None:[](#l46.42)
@@ -1747,7 +1747,7 @@ else: def init(self, file, events=None): self._close_file = False if not hasattr(file, 'read'):
file = open(file, 'rb', cloexec=True)[](#l46.47)
file = open(file, 'rb')[](#l46.48) self._close_file = True[](#l46.49) self._file = file[](#l46.50) self._events = [][](#l46.51)
--- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -321,7 +321,7 @@ def prepare_input_source(source, base="" sysidfilename = os.path.join(basehead, sysid) if os.path.isfile(sysidfilename): source.setSystemId(sysidfilename)
f = open(sysidfilename, "rb", cloexec=True)[](#l47.7)
f = open(sysidfilename, "rb")[](#l47.8) else:[](#l47.9) source.setSystemId(urllib.parse.urljoin(base, sysid))[](#l47.10) f = urllib.request.urlopen(source.getSystemId())[](#l47.11)
--- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -178,7 +178,7 @@ def is_zipfile(filename): if hasattr(filename, "read"): result = _check_zipfile(fp=filename) else:
with open(filename, "rb", cloexec=True) as fp:[](#l48.7)
except OSError: passwith open(filename, "rb") as fp:[](#l48.8) result = _check_zipfile(fp)[](#l48.9)
@@ -899,11 +899,11 @@ class ZipFile: self.filename = file modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'} try:
self.fp = io.open(file, modeDict[mode], cloexec=True)[](#l48.16)
self.fp = io.open(file, modeDict[mode])[](#l48.17) except OSError:[](#l48.18) if mode == 'a':[](#l48.19) mode = key = 'w'[](#l48.20)
self.fp = io.open(file, modeDict[mode], cloexec=True)[](#l48.21)
self.fp = io.open(file, modeDict[mode])[](#l48.22) else:[](#l48.23) raise[](#l48.24) else:[](#l48.25)
@@ -1109,7 +1109,7 @@ class ZipFile: if self._filePassed: zef_file = self.fp else:
zef_file = io.open(self.filename, 'rb', cloexec=True)[](#l48.30)
zef_file = io.open(self.filename, 'rb')[](#l48.31)
try: # Make sure we have an info object @@ -1240,7 +1240,7 @@ class ZipFile: return targetpath with self.open(member, pwd=pwd) as source, [](#l48.38)
open(targetpath, "wb", cloexec=True) as target:[](#l48.39)
open(targetpath, "wb") as target:[](#l48.40) shutil.copyfileobj(source, target)[](#l48.41)
return targetpath @@ -1310,7 +1310,7 @@ class ZipFile: return cmpr = _get_compressor(zinfo.compress_type)
with open(filename, "rb", cloexec=True) as fp:[](#l48.48)
with open(filename, "rb") as fp:[](#l48.49) # Must overwrite CRC and sizes with correct data later[](#l48.50) zinfo.CRC = CRC = 0[](#l48.51) zinfo.compress_size = compress_size = 0[](#l48.52)
@@ -1710,7 +1710,7 @@ def main(args = None): tgtdir = os.path.dirname(tgt) if not os.path.exists(tgtdir): os.makedirs(tgtdir)
with open(tgt, 'wb', cloexec=True) as fp:[](#l48.57)
with open(tgt, 'wb') as fp:[](#l48.58) fp.write(zf.read(path))[](#l48.59)