From c8cc2a1e276d475123dea8b66284e70e563f253c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miklo=CC=81s=20Tusz?= Date: Tue, 8 Mar 2022 11:49:03 -0800 Subject: [PATCH] scripts: Migrate `check_whitespace.py` to python3 Modified strings used in pattern matching to b-strings as are expected with python3. Signed-off-by: Miklos Tusz --- scripts/check_whitespace.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/check_whitespace.py b/scripts/check_whitespace.py index da4cadab..fe8c7ae8 100755 --- a/scripts/check_whitespace.py +++ b/scripts/check_whitespace.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Check files for whitespace problems # # Copyright (C) 2018 Kevin O'Connor @@ -29,7 +29,7 @@ def check_file(filename): # Do checks is_source_code = any([filename.endswith(s) for s in ['.c', '.h', '.py']]) lineno = 0 - for lineno, line in enumerate(data.split('\n')): + for lineno, line in enumerate(data.split(b'\n')): # Verify line is valid utf-8 try: line = line.decode('utf-8') @@ -53,9 +53,9 @@ def check_file(filename): # Check for more than 80 characters if is_source_code and len(line) > 80: report_error(filename, lineno, "Line longer than 80 characters") - if not data.endswith('\n'): + if not data.endswith(b'\n'): report_error(filename, lineno, "No newline at end of file") - if data.endswith('\n\n'): + if data.endswith(b'\n\n'): report_error(filename, lineno, "Extra newlines at end of file") def main():