Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions basicparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,22 +666,30 @@ def __openstmt(self):
if accessMode == "r+":
# By checking the 'newlines' attribute the appropriate adjustment for
# the file being opened can be determined.

try:
# newline attribute is only set after a line is read
# manually identify newlines in case newlines attribute isn't supported
fileline = self.__file_handles[filenum].readline()
newlines = ""
for ichar in range(len(fileline)-1,-1,-1):
if fileline[ichar] not in ['\n','\r']:
break
newlines = fileline[ichar:]
except:
newlines = None

if hasattr(self.__file_handles[filenum],'newlines'):
try:
# newline attribute is only set after a line is read
self.__file_handles[filenum].readline()
except:
pass
newlines = self.__file_handles[filenum].newlines
else:
newlines = None


self.__file_handles[filenum].seek(0)
filelen = 0
if newlines != None:

if newlines is not None:
newlineAdj = len(newlines) - 1
else:
# If using version of Python that doesn't have newlines attribute
# If we wern't able to determine an appropriate value and
# using version of Python that doesn't have newlines attribute
# use adjustment appropriate for Windows formatted files
newlineAdj = 1

Expand Down