Commits

Ali Gholami Rudi  committed 6237608

fscommands: handling mac line ending

  • Participants
  • Parent commits 95e9177

Comments (0)

Files changed (2)

File rope/base/ast.py

     # NOTE: the raw string should be given to `compile` function
     if isinstance(source, unicode):
         source = fscommands.unicode_to_file_data(source)
-    if '\r\n' in source:
-        source = source.replace('\r\n', '\n')
+    if '\r' in source:
+        source = source.replace('\r\n', '\n').replace('\r', '\n')
     if not source.endswith('\n'):
         source += '\n'
     try:

File rope/base/fscommands.py

 
 def file_data_to_unicode(data, encoding=None):
     result = _decode_data(data, encoding)
-    if '\r\n' in result:
-        return result.replace('\r\n', '\n')
+    if '\r' in result:
+        result = result.replace('\r\n', '\n').replace('\r', '\n')
     return result
 
 def _decode_data(data, encoding):