Skip to content

Commit

Permalink
bpo-40107: stop using os.open() to implement pathlib.Path.open()
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Apr 7, 2021
1 parent b05440c commit 4246f5d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class _NormalAccessor(_Accessor):

stat = os.stat

open = os.open
open = io.open

listdir = os.listdir

Expand Down Expand Up @@ -1087,10 +1087,6 @@ def __exit__(self, t, v, tb):
# removed in the future.
pass

def _opener(self, name, flags, mode=0o666):
# A stub for the opener argument to built-in open()
return self._accessor.open(self, flags, mode)

# Public API

@classmethod
Expand Down Expand Up @@ -1212,8 +1208,8 @@ def open(self, mode='r', buffering=-1, encoding=None,
"""
if "b" not in mode:
encoding = io.text_encoding(encoding)
return io.open(self, mode, buffering, encoding, errors, newline,
opener=self._opener)
return self._accessor.open(self, mode, buffering, encoding, errors,
newline)

def read_bytes(self):
"""
Expand Down

0 comments on commit 4246f5d

Please sign in to comment.