[Python-checkins] cpython: use the same line terminator everywhere

tarek.ziade python-checkins at python.org
Sat May 21 19:45:55 CEST 2011


http://hg.python.org/cpython/rev/391aa4da36b5
changeset:   70259:391aa4da36b5
user:        Tarek Ziade <tarek at ziade.org>
date:        Sat May 21 19:45:48 2011 +0200
summary:
  use the same line terminator everywhere

files:
  Lib/packaging/command/install_distinfo.py |  4 ++--
  Lib/packaging/database.py                 |  6 ++++--
  Lib/packaging/tests/test_database.py      |  7 +++++--
  3 files changed, 11 insertions(+), 6 deletions(-)


diff --git a/Lib/packaging/command/install_distinfo.py b/Lib/packaging/command/install_distinfo.py
--- a/Lib/packaging/command/install_distinfo.py
+++ b/Lib/packaging/command/install_distinfo.py
@@ -110,7 +110,7 @@
                     logger.info('creating %s', resources_path)
                     with open(resources_path, 'wb') as f:
                         writer = csv.writer(f, delimiter=',',
-                                            lineterminator=os.linesep,
+                                            lineterminator='\n',
                                             quotechar='"')
                         for tuple in install_data.get_resources_out():
                             writer.writerow(tuple)
@@ -122,7 +122,7 @@
                 logger.info('creating %s', record_path)
                 with open(record_path, 'w', encoding='utf-8') as f:
                     writer = csv.writer(f, delimiter=',',
-                                        lineterminator=os.linesep,
+                                        lineterminator='\n',
                                         quotechar='"')
 
                     install = self.get_finalized_command('install_dist')
diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py
--- a/Lib/packaging/database.py
+++ b/Lib/packaging/database.py
@@ -159,7 +159,8 @@
 
     def _get_records(self, local=False):
         with self.get_distinfo_file('RECORD') as record:
-            record_reader = csv.reader(record, delimiter=',')
+            record_reader = csv.reader(record, delimiter=',',
+                                       lineterminator='\n')
             # XXX needs an explaining comment
             for row in record_reader:
                 path, checksum, size = (row[:] +
@@ -171,7 +172,8 @@
 
     def get_resource_path(self, relative_path):
         with self.get_distinfo_file('RESOURCES') as resources_file:
-            resources_reader = csv.reader(resources_file, delimiter=',')
+            resources_reader = csv.reader(resources_file, delimiter=',',
+                                           lineterminator='\n')
             for relative, destination in resources_reader:
                 if relative == relative_path:
                     return destination
diff --git a/Lib/packaging/tests/test_database.py b/Lib/packaging/tests/test_database.py
--- a/Lib/packaging/tests/test_database.py
+++ b/Lib/packaging/tests/test_database.py
@@ -111,7 +111,8 @@
             record_file = os.path.join(distinfo_dir, 'RECORD')
             with open(record_file, 'w') as file:
                 record_writer = csv.writer(
-                    file, delimiter=',', quoting=csv.QUOTE_NONE)
+                    file, delimiter=',', quoting=csv.QUOTE_NONE,
+                    lineterminator='\n')
 
                 dist_location = distinfo_dir.replace('.dist-info', '')
 
@@ -125,9 +126,11 @@
                 record_writer.writerow([relpath(record_file, sys.prefix)])
 
             with open(record_file) as file:
-                record_reader = csv.reader(file)
+                record_reader = csv.reader(file, lineterminator='\n')
                 record_data = {}
                 for row in record_reader:
+                    if row == []:
+                        continue
                     path, md5_, size = (row[:] +
                                         [None for i in range(len(row), 3)])
                     record_data[path] = md5_, size

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list