1. Tarek Ziadé
  2. rope_py3k


Ali Gholami Rudi  committed 6237608

fscommands: handling mac line ending

  • Participants
  • Parent commits 95e9177
  • Branches trunk

Comments (0)

Files changed (2)

File rope/base/ast.py

View file
     # 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'

File rope/base/fscommands.py

View file
 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):