diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-24 03:05:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 03:05:10 (GMT) |
commit | 22f06d6ce344ba80f2213fbe12fe951ca77cab4e (patch) | |
tree | 570a7b688d7150d242159d6a55576e13696dd45a /Lib/fileinput.py | |
parent | e8edbda8972e83c86db1cb5b51ba9002c4923b6e (diff) | |
download | cpython-22f06d6ce344ba80f2213fbe12fe951ca77cab4e.zip cpython-22f06d6ce344ba80f2213fbe12fe951ca77cab4e.tar.gz cpython-22f06d6ce344ba80f2213fbe12fe951ca77cab4e.tar.bz2 |
gh-93157: Fix fileinput didn't support `errors` in `inplace` mode (GH-95128)
(cherry picked from commit 5c7f3bcdafedd60a385e8ca5403bc6b0b7a862b3)
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Diffstat (limited to 'Lib/fileinput.py')
-rw-r--r-- | Lib/fileinput.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/fileinput.py b/Lib/fileinput.py index 9f41c18..e234dc9 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -335,18 +335,21 @@ class FileInput: pass # The next few lines may raise OSError os.rename(self._filename, self._backupfilename) - self._file = open(self._backupfilename, self._mode, encoding=encoding) + self._file = open(self._backupfilename, self._mode, + encoding=encoding, errors=self._errors) try: perm = os.fstat(self._file.fileno()).st_mode except OSError: - self._output = open(self._filename, self._write_mode, encoding=encoding) + self._output = open(self._filename, self._write_mode, + encoding=encoding, errors=self._errors) else: mode = os.O_CREAT | os.O_WRONLY | os.O_TRUNC if hasattr(os, 'O_BINARY'): mode |= os.O_BINARY fd = os.open(self._filename, mode, perm) - self._output = os.fdopen(fd, self._write_mode, encoding=encoding) + self._output = os.fdopen(fd, self._write_mode, + encoding=encoding, errors=self._errors) try: os.chmod(self._filename, perm) except OSError: |