mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-40107: Switch to using io.open() for pathlib.Path.open() (GH-25240)
Previously we had identical behaviour but only allowed accessors to override os.open(). This change allows the override to also construct the IO wrapper as well.
This commit is contained in:
parent
2d7fdc9073
commit
11c3bd3f6d
1 changed files with 3 additions and 7 deletions
|
@ -350,7 +350,7 @@ class _NormalAccessor(_Accessor):
|
||||||
|
|
||||||
stat = os.stat
|
stat = os.stat
|
||||||
|
|
||||||
open = os.open
|
open = io.open
|
||||||
|
|
||||||
listdir = os.listdir
|
listdir = os.listdir
|
||||||
|
|
||||||
|
@ -1046,10 +1046,6 @@ class Path(PurePath):
|
||||||
# removed in the future.
|
# removed in the future.
|
||||||
pass
|
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
|
# Public API
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1171,8 +1167,8 @@ class Path(PurePath):
|
||||||
"""
|
"""
|
||||||
if "b" not in mode:
|
if "b" not in mode:
|
||||||
encoding = io.text_encoding(encoding)
|
encoding = io.text_encoding(encoding)
|
||||||
return io.open(self, mode, buffering, encoding, errors, newline,
|
return self._accessor.open(self, mode, buffering, encoding, errors,
|
||||||
opener=self._opener)
|
newline)
|
||||||
|
|
||||||
def read_bytes(self):
|
def read_bytes(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue