Skip to content

Commit

Permalink
pystache/common.py: test failures in Windows due to CRs
Browse files Browse the repository at this point in the history
* cleaned up from defunkt/pystache#193

Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Nov 9, 2020
1 parent fb40760 commit c5d723a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pystache/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ def read(path):
# read() method returns byte strings (strings of type `str` in Python 2),
# whereas in Python 3, the file object returns unicode strings (strings
# of type `str` in Python 3).
f = open(path, 'rb')
if version_info < (3, ):
f = open(path, 'rbU')
else:
f = open(path, 'r')
# We avoid use of the with keyword for Python 2.4 support.
try:
return f.read()
if version_info < (3, ):
return f.read()
return f.read().encode('utf_8')
finally:
f.close()

Expand Down

0 comments on commit c5d723a

Please sign in to comment.