Skip to content

Commit 1a629df

Browse files
Merge pull request #116 from montefra/open_U_newline
readlines: use mode=r in py3 TODO: add changelog
2 parents 97efc1c + 4e7c686 commit 1a629df

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

py/_path/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,16 @@ def read(self, mode='r'):
170170
def readlines(self, cr=1):
171171
""" read and return a list of lines from the path. if cr is False, the
172172
newline will be removed from the end of each line. """
173+
if sys.version_info < (3, ):
174+
mode = 'rU'
175+
else: # python 3 deprecates mode "U" in favor of "newline" option
176+
mode = 'r'
177+
173178
if not cr:
174-
content = self.read('rU')
179+
content = self.read(mode)
175180
return content.split('\n')
176181
else:
177-
f = self.open('rU')
182+
f = self.open(mode)
178183
try:
179184
return f.readlines()
180185
finally:

0 commit comments

Comments
 (0)