Commit 6d2064179758ae0fa4c2b41f7ee6e179cd429b7b
1 parent
e9d29e09
msodde: open CSV files with correct mode & newlines
This makes usage of uopen unnecessary.
Showing
1 changed file
with
5 additions
and
1 deletions
oletools/msodde.py
| @@ -772,7 +772,11 @@ def process_csv(filepath): | @@ -772,7 +772,11 @@ def process_csv(filepath): | ||
| 772 | """ | 772 | """ |
| 773 | 773 | ||
| 774 | results = [] | 774 | results = [] |
| 775 | - with open(filepath, 'r') as file_handle: | 775 | + if sys.version_info.major <= 2: |
| 776 | + open_arg = dict(mode='rb') | ||
| 777 | + else: | ||
| 778 | + open_arg = dict(newline='') | ||
| 779 | + with open(filepath, **open_arg) as file_handle: | ||
| 776 | results, dialect = process_csv_dialect(file_handle, CSV_DELIMITERS) | 780 | results, dialect = process_csv_dialect(file_handle, CSV_DELIMITERS) |
| 777 | is_small = file_handle.tell() < CSV_SMALL_THRESH | 781 | is_small = file_handle.tell() < CSV_SMALL_THRESH |
| 778 | 782 |