[RFC PATCH v2 7/8] python3: Open files in text instead of binary mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We use text operations on the contents after reading them.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
This seems reasonable and works correctly AFAICT, but I'm
not 100% confident it's the right way to address the issue.

 src/esx/esx_vi_generator.py        | 4 ++--
 src/hyperv/hyperv_wmi_generator.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 2f3c88812d..6ce017d794 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1327,7 +1327,7 @@ def open_and_print(filename):
     else:
         print("  GEN      " + filename)
 
-    return open(filename, "wb")
+    return open(filename, "wt")
 
 
 
@@ -1435,7 +1435,7 @@ block = None
 
 
 # parse input file
-for line in file(input_filename, "rb").readlines():
+for line in open(input_filename, "rt").readlines():
     number += 1
 
     if "#" in line:
diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
index 1cf16a7836..7dc11ba905 100755
--- a/src/hyperv/hyperv_wmi_generator.py
+++ b/src/hyperv/hyperv_wmi_generator.py
@@ -396,7 +396,7 @@ def open_and_print(filename):
     else:
         print("  GEN      " + filename)
 
-    return open(filename, "wb")
+    return open(filename, "wt")
 
 
 
@@ -468,7 +468,7 @@ def main():
     number = 0
     block = None
 
-    for line in file(input_filename, "rb").readlines():
+    for line in open(input_filename, "rt").readlines():
         number += 1
 
         if "#" in line:
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux