mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
gh-110745: add a newline argument to pathlib.Path.read_text (#110880)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
d857d5331a
commit
9d70831cb7
4 changed files with 22 additions and 3 deletions
|
@ -950,12 +950,12 @@ class _PathBase(PurePath):
|
|||
with self.open(mode='rb') as f:
|
||||
return f.read()
|
||||
|
||||
def read_text(self, encoding=None, errors=None):
|
||||
def read_text(self, encoding=None, errors=None, newline=None):
|
||||
"""
|
||||
Open the file in text mode, read it, and close the file.
|
||||
"""
|
||||
encoding = io.text_encoding(encoding)
|
||||
with self.open(mode='r', encoding=encoding, errors=errors) as f:
|
||||
with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
|
||||
return f.read()
|
||||
|
||||
def write_bytes(self, data):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue